From 4f1cccb1389305a5d76ec26408295e2b4c7c1ce5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 11 Nov 2016 22:05:17 +0100 Subject: [PATCH] Enable removing of all comments (except for Copyright notices) when preprocessing code, and reduce the indentation level --- external/builder/preprocessor2.js | 13 ++++++++++--- gulpfile.js | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/external/builder/preprocessor2.js b/external/builder/preprocessor2.js index 02eb689a3..c1c7d84e0 100644 --- a/external/builder/preprocessor2.js +++ b/external/builder/preprocessor2.js @@ -203,8 +203,15 @@ function fixComments(ctx, node) { while (i < node.leadingComments.length) { var type = node.leadingComments[i].type; var value = node.leadingComments[i].value; - if (type === 'Block' && - /^\s*(globals|jshint|falls through|umdutils)\b/.test(value)) { + + if (ctx.saveComments === 'copyright') { + // Remove all comments, except Copyright notices and License headers. + if (!(type === 'Block' && /\bcopyright\b/i.test(value))) { + node.leadingComments.splice(i, 1); + continue; + } + } else if (type === 'Block' && + /^\s*(globals|jshint|falls through|umdutils)\b/.test(value)) { node.leadingComments.splice(i, 1); continue; } @@ -245,7 +252,7 @@ function preprocessPDFJSCode(ctx, code) { var saveComments = !!ctx.saveComments; var format = ctx.format || { indent: { - style: ' ', + style: ' ', adjustMultilineComment: saveComments, } }; diff --git a/gulpfile.js b/gulpfile.js index e0149cfb1..b7f2d4248 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -133,7 +133,7 @@ function bundle(filename, outfilename, pathPrefix, initFiles, amdName, defines, var p2 = require('./external/builder/preprocessor2.js'); var ctx = { rootPath: __dirname, - saveComments: true, + saveComments: 'copyright', defines: builder.merge(defines, { BUNDLE_VERSION: versionInfo.version, BUNDLE_BUILD: versionInfo.commit,