提交 958bdd6a 编写于 作者: I isidor

copyrights: use nicer gulp globing

fixes #260
上级 eceef7a6
...@@ -9,53 +9,13 @@ var copyright = [ ...@@ -9,53 +9,13 @@ var copyright = [
' *--------------------------------------------------------------------------------------------*/' ' *--------------------------------------------------------------------------------------------*/'
].join('\n'); ].join('\n');
var ignoreList = [
'/src/vs/languages/typescript/common/lib/lib.d.ts',
'/src/vs/languages/typescript/common/lib/lib.es6.d.ts',
'/src/vs/languages/typescript/common/lib/typescriptServices.d.ts',
'/src/vs/workbench/parts/emmet/node/emmet.d.ts',
'/src/vs/editor/standalone-languages/swift.ts',
'/src/vs/workbench/browser/media/octicons/octicons.css',
'/src/vs/base/test/node/encoding/fixtures/some_utf16be.css',
'/src/vs/base/test/node/encoding/fixtures/some_utf16le.css',
'/src/vs/workbench/services/search/test/node/fixtures/site.css',
'/src/vs/workbench/services/search/test/node/fixtures/some_utf16be.css',
'/src/vs/workbench/services/search/test/node/fixtures/some_utf16le.css',
'/src/vs/workbench/services/files/test/node/fixtures/service/some_utf16le.css',
'/extensions/lib.core.d.ts',
'/extensions/node.d.ts',
'/extensions/csharp-o/src/typings/applicationinsights.d.ts',
'/extensions/typescript/out/lib/lib.core.d.ts',
'/extensions/typescript/out/lib/lib.core.es6.d.ts',
'/extensions/typescript/out/lib/lib.d.ts',
'/extensions/typescript/out/lib/lib.dom.d.ts',
'/extensions/typescript/out/lib/lib.es6.d.ts',
'/extensions/typescript/out/lib/lib.scriptHost.d.ts',
'/extensions/typescript/out/lib/lib.webworker.d.ts',
'/extensions/typescript/src/lib/lib.core.d.ts',
'/extensions/typescript/src/lib/lib.core.es6.d.ts',
'/extensions/typescript/src/lib/lib.d.ts',
'/extensions/typescript/src/lib/lib.dom.d.ts',
'/extensions/typescript/src/lib/lib.es6.d.ts',
'/extensions/typescript/src/lib/lib.scriptHost.d.ts',
'/extensions/typescript/src/lib/lib.webworker.d.ts',
'/extensions/csharp-o/src/typings/semver/semver.d.ts'
];
function ignore(filePath) {
filePath = path.posix.normalize(filePath);
return ignoreList.some(function(p) {
return filePath.indexOf(p) !== -1;
});
}
exports.copyrights = function () { exports.copyrights = function () {
return es.mapSync(function (file) { return es.mapSync(function (file) {
if (file.contents) { if (file.contents) {
var contents = file.contents.toString('utf8'); var contents = file.contents.toString('utf8');
if (contents.indexOf(copyright) !== 0 && !ignore(file.path)) { if (contents.indexOf(copyright) !== 0) {
throw new Error('File ' + file.path + ' does not contain copyright statement.'); throw new Error('File ' + file.path + ' does not contain copyright statement.');
} }
} }
...@@ -67,7 +27,7 @@ exports.insertCopyrights = function() { ...@@ -67,7 +27,7 @@ exports.insertCopyrights = function() {
if (file.contents) { if (file.contents) {
var contents = file.contents.toString('utf8'); var contents = file.contents.toString('utf8');
if (contents.indexOf(copyright) !== 0 && !ignore(file.path)) { if (contents.indexOf(copyright) !== 0) {
contents = copyright + '\n\n' + contents; contents = copyright + '\n\n' + contents;
fs.writeFileSync(file.path, contents, 'utf8'); fs.writeFileSync(file.path, contents, 'utf8');
} }
......
...@@ -163,12 +163,21 @@ gulp.task('fix-whitespace-style', function() { ...@@ -163,12 +163,21 @@ gulp.task('fix-whitespace-style', function() {
return gulp.src(WHITESPACE_FILES, { base: '.' }).pipe(style({whitespace:true})).pipe(gulp.dest('.')); return gulp.src(WHITESPACE_FILES, { base: '.' }).pipe(style({whitespace:true})).pipe(gulp.dest('.'));
}); });
var COPYRIGHTS_FILES = WHITESPACE_FILES.concat([
'!**/*.json',
'!**/*.html',
'!**/test/**',
'!**/*.md',
'!**/*.sh',
'!**/*.txt',
'!src/vs/editor/standalone-languages/swift.ts',
]);
gulp.task('copyrights', function() { gulp.task('copyrights', function() {
return gulp.src(['src/vs/**/*.ts', 'src/vs/**/*.css', 'extensions/**/*.ts', 'extensions/**/*.css']).pipe(copyrights.copyrights()); return gulp.src(COPYRIGHTS_FILES, { base: '.' }).pipe(copyrights.copyrights());
}); });
gulp.task('insert-copyrights', function() { gulp.task('insert-copyrights', function() {
return gulp.src(['src/vs/**/*.ts', 'src/vs/**/*.css', 'extensions/**/*.ts', 'extensions/**/*.css']).pipe(copyrights.insertCopyrights()); return gulp.src(COPYRIGHTS_FILES, { base: '.' }).pipe(copyrights.insertCopyrights());
}); });
gulp.task('test', function () { gulp.task('test', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册