Skip to content

Commit ff632dd

Browse files
authored
Add new gulp task to run hygiene on diffs with master (#12)
1 parent 451ec80 commit ff632dd

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
{
66
"type": "node",
77
"request": "launch",
8-
"name": "Gulp compile-webviews",
8+
"name": "Gulp hygiene-branch",
99
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
1010
"args": [
11-
"compile-webviews"
11+
"hygiene-branch"
1212
]
1313
},
1414
{

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
"problemMatcher": []
6363
},
6464
{
65-
"label": "Hygiene All",
65+
"label": "Hygiene Watch Branch",
6666
"type": "gulp",
67-
"task": "hygiene",
67+
"task": "hygiene-watch-branch",
6868
"isBackground": true,
6969
"presentation": {
7070
"echo": true,

gulpfile.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,14 @@ gulp.task('debugger-coverage', () => buildDebugAdapterCoverage());
9999

100100
gulp.task('hygiene-watch', () => gulp.watch(tsFilter, debounce(() => run({ mode: 'changes', skipFormatCheck: true, skipIndentationCheck: true, skipCopyrightCheck: true }), 100)));
101101

102+
gulp.task('hygiene-watch-branch', () => gulp.watch(tsFilter, debounce(() => run({ mode: 'diffMaster', skipFormatCheck: true, skipIndentationCheck: true, skipCopyrightCheck: true }), 100)));
103+
102104
gulp.task('hygiene-all', () => run({ mode: 'all' }));
103105

104106
gulp.task('hygiene-modified', ['compile'], () => run({ mode: 'changes' }));
105107

108+
gulp.task('hygiene-branch', ['compile'], () => run({ mode: 'diffMaster' }));
109+
106110
gulp.task('clean', ['output:clean', 'cover:clean'], () => { });
107111

108112
gulp.task('output:clean', () => del(['coverage', 'debug_coverage*']));
@@ -266,7 +270,7 @@ function buildDebugAdapterCoverage() {
266270

267271
/**
268272
* @typedef {Object} hygieneOptions - creates a new type named 'SpecialType'
269-
* @property {'changes'|'staged'|'all'|'compile'} [mode=] - Mode.
273+
* @property {'changes'|'staged'|'all'|'compile'|'diffMaster'} [mode=] - Mode.
270274
* @property {boolean=} skipIndentationCheck - Skip indentation checks.
271275
* @property {boolean=} skipFormatCheck - Skip format checks.
272276
* @property {boolean=} skipCopyrightCheck - Skip copyright checks.
@@ -590,6 +594,13 @@ function getModifiedFilesSync() {
590594
.filter(l => _.intersection(['M', 'A', 'R', 'C', 'U', '?'], l.substring(0, 2).trim().split('')).length > 0)
591595
.map(l => path.join(__dirname, l.substring(2).trim()));
592596
}
597+
function getDifferentFromMasterFilesSync() {
598+
const out = cp.execSync('git diff --name-status master', { encoding: 'utf8' });
599+
return out
600+
.split(/\r?\n/)
601+
.filter(l => !!l)
602+
.map(l => path.join(__dirname, l.substring(2).trim()));
603+
}
593604

594605
/**
595606
* @param {hygieneOptions} options
@@ -615,6 +626,10 @@ function getFileListToProcess(options) {
615626
return getStagedFilesSync();
616627
}
617628

629+
if (options && options.mode === 'diffMaster') {
630+
return getDifferentFromMasterFilesSync();
631+
}
632+
618633
return all;
619634
}
620635
exports.hygiene = hygiene;

0 commit comments

Comments
 (0)