mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Enable removing of all comments (except for Copyright notices) when preprocessing code, and reduce the indentation level
This commit is contained in:
parent
a139c75774
commit
4f1cccb138
2 changed files with 11 additions and 4 deletions
13
external/builder/preprocessor2.js
vendored
13
external/builder/preprocessor2.js
vendored
|
@ -203,8 +203,15 @@ function fixComments(ctx, node) {
|
||||||
while (i < node.leadingComments.length) {
|
while (i < node.leadingComments.length) {
|
||||||
var type = node.leadingComments[i].type;
|
var type = node.leadingComments[i].type;
|
||||||
var value = node.leadingComments[i].value;
|
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);
|
node.leadingComments.splice(i, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +252,7 @@ function preprocessPDFJSCode(ctx, code) {
|
||||||
var saveComments = !!ctx.saveComments;
|
var saveComments = !!ctx.saveComments;
|
||||||
var format = ctx.format || {
|
var format = ctx.format || {
|
||||||
indent: {
|
indent: {
|
||||||
style: ' ',
|
style: ' ',
|
||||||
adjustMultilineComment: saveComments,
|
adjustMultilineComment: saveComments,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,7 +133,7 @@ function bundle(filename, outfilename, pathPrefix, initFiles, amdName, defines,
|
||||||
var p2 = require('./external/builder/preprocessor2.js');
|
var p2 = require('./external/builder/preprocessor2.js');
|
||||||
var ctx = {
|
var ctx = {
|
||||||
rootPath: __dirname,
|
rootPath: __dirname,
|
||||||
saveComments: true,
|
saveComments: 'copyright',
|
||||||
defines: builder.merge(defines, {
|
defines: builder.merge(defines, {
|
||||||
BUNDLE_VERSION: versionInfo.version,
|
BUNDLE_VERSION: versionInfo.version,
|
||||||
BUNDLE_BUILD: versionInfo.commit,
|
BUNDLE_BUILD: versionInfo.commit,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue