1
0
Эх сурвалжийг харах

append to monaco.d.ts from all plugins

Alex Dima 9 жил өмнө
parent
commit
3c8bc9b380
2 өөрчлөгдсөн 32 нэмэгдсэн , 11 устгасан
  1. 29 8
      gulpfile.js
  2. 3 3
      package.json

+ 29 - 8
gulpfile.js

@@ -35,7 +35,7 @@ gulp.task('release', ['clean-release'], function() {
 			'node_modules/monaco-editor-core/monaco.d.ts',
 			'node_modules/monaco-editor-core/ThirdPartyNotices.txt',
 			'README.md'
-		]).pipe(gulp.dest('release'))
+		]).pipe(addPluginDTS()).pipe(gulp.dest('release'))
 	)
 });
 
@@ -48,13 +48,6 @@ function releaseOne(type) {
 	)
 }
 
-function mergePluginsContribsIntoCore(coreStream) {
-	return (
-		coreStream
-		.pipe(addPluginContribs())
-	);
-}
-
 function pluginStreams(destinationPath) {
 	return es.merge(
 		metadata.METADATA.PLUGINS.map(function(plugin) {
@@ -127,3 +120,31 @@ function addPluginContribs() {
 		this.emit('data', data);
 	});
 }
+
+/**
+ * Edit monaco.d.ts:
+ * - append monaco.d.ts from plugins
+ */
+function addPluginDTS() {
+	return es.through(function(data) {
+		if (!/monaco\.d\.ts$/.test(data.path)) {
+			this.emit('data', data);
+			return;
+		}
+		var contents = data.contents.toString();
+
+		var extraContent = [];
+		metadata.METADATA.PLUGINS.forEach(function(plugin) {
+			var dtsPath = path.join(plugin.path, 'monaco.d.ts');
+			try {
+				extraContent.push(fs.readFileSync(dtsPath).toString());
+			} catch (err) {
+				return;
+			}
+		});
+
+		contents += '\n' + extraContent.join('\n');
+		data.contents = new Buffer(contents);
+		this.emit('data', data);
+	});
+}

+ 3 - 3
package.json

@@ -17,9 +17,9 @@
     "event-stream": "^3.3.2",
     "gulp": "^3.9.1",
     "http-server": "^0.9.0",
-    "monaco-editor-core": "0.3.1",
-    "monaco-languages": "0.1.1",
-    "monaco-typescript": "0.1.1",
+    "monaco-editor-core": "0.4.0",
+    "monaco-languages": "0.2.0",
+    "monaco-typescript": "0.2.0",
     "rimraf": "^2.5.2"
   }
 }