aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorGravatar Daniel Smith <rdnlsmith@gmail.com> 2019-05-04 21:53:39 -0400
committerGravatar Daniel Smith <rdnlsmith@gmail.com> 2019-05-04 21:53:39 -0400
commitd567d0727c5ee72376ead5b7aa0195187a8d8381 (patch)
treea307a21111ef1773e4d0d23a9274edaf3fd024e1 /gulpfile.js
parentdb2bde1d1ba9a32e6bd7b7dc81ec06bb695ebf17 (diff)
Add Gulp for live theme editing
Run `npm start` from terminal to launch an extension host window and start watching the TypeScript source files. You can still open VS Code and press F5 if using a version older than 1.30 (January 2019).
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..cb4a983
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,68 @@
+var gulp = require('gulp');
+var clean = require('gulp-clean');
+var ts = require('gulp-typescript');
+var fs = require('fs');
+var glob = require('glob');
+var spawnSync = require('child_process').spawnSync;
+var through = require('through2');
+
+var tsProject = ts.createProject('tsconfig.json');
+
+function cleanTypeScript() {
+ return gulp.src('themes/ts-built', {read: false})
+ .pipe(clean());
+}
+
+function buildTypeScript() {
+ return tsProject.src()
+ .pipe(tsProject())
+ .js.pipe(gulp.dest('./themes/ts-built'));
+}
+
+function generateJson() {
+ return gulp.src('themes/ts-built/**/*.js')
+ .pipe(through.obj(function(file, encoding, callback) {
+ spawnSync('node', [ file.path ]);
+ callback(null, file);
+ }));
+}
+
+function copyJson() {
+ return gulp.src('themes/ts-built/**/*.json')
+ .pipe(gulp.dest('themes'));
+}
+
+function inject(done) {
+ var themes = [];
+ glob.sync('./themes/dark/*.json').forEach(function(file) {
+ var theme = require(file);
+ themes.push({
+ label: theme.name,
+ uiTheme: 'vs-dark',
+ path: file
+ });
+ });
+ glob.sync('./themes/light/*.json').forEach(function(file) {
+ var theme = require(file);
+ themes.push({
+ label: theme.name,
+ uiTheme: 'vs',
+ path: file
+ });
+ });
+ var package = require('./package.json');
+ package.contributes.themes = themes;
+ fs.writeFile('./package.json', JSON.stringify(package, null, 2), function(err) {
+ if (err) return console.log(err);
+ console.log('package.json updated');
+ });
+ done();
+}
+
+gulp.task('build', gulp.series(cleanTypeScript, buildTypeScript, generateJson, copyJson, inject));
+
+gulp.task('default', gulp.series('build'));
+
+gulp.task('watch', gulp.series('build', function() {
+ gulp.watch('themes/src/**/*.ts', gulp.series('build'));
+})); \ No newline at end of file