-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
69 lines (61 loc) · 1.86 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var gulp = require('gulp');
var taskListing = require('gulp-task-listing');
var path = require('canonical-path');
var _ = require('lodash');
var argv = require('yargs').argv;
var rewriter = require('./rewriter');
gulp.task('help', taskListing.withFilters(function(taskName) {
var isSubTask = taskName.substr(0,1) == "_";
return isSubTask;
}, function(taskName) {
var shouldRemove = taskName === 'default';
return shouldRemove;
}));
gulp.task('rewrite', function(done) {
var filePath = argv.file || argv.f || (argv._.length > 1 && argv._[1]);
if (!filePath) {
console.log('must pass in at least one parameter which may be');
console.log(' either a folder/file name or ');
console.log(' any collection of the following flags ');
console.log(' -f[ile]={folder/fileName} -suffix={suffix} -outDir={output folder} ');
return;
}
var options;
if (argv.outDir || argv.suffix) {
options = {
outDir: argv.outDir,
suffix: argv.suffix
}
}
// use default options if none is given.
rewriter.rewrite(filePath, options).then(done);
});
//// no longer used - compile step moved into main.js
//function tscCompile(filePath) {
// var fstat = fs.lstatSync(filePath);
// var folderPath, options, srcGlob;
// if (fstat.isDirectory()) {
// folderPath = filePath;
// options = {};
// srcGlob = path.join(folderPath, '*.ts');
// } else {
// folderPath = path.dirname(filePath);
// options = { files: [ filePath] };
// srcGlob = filePath;
// }
//
// var options = {
// "target": "ES5",
// "module": "commonjs",
// "sourceMap": true,
// "emitDecoratorMetadata": true,
// "experimentalDecorators": true,
// "removeComments": false
// };
//
// var tsResult = gulp.src(srcGlob)
// .pipe(tsc(options))
// .pipe(gulp.dest(folderPath));
// return streamToPromise(tsResult);
//}
gulp.task('default', ['help']);