Keep comments with specific keywords

This commit is contained in:
sanex3339
2017-12-05 11:13:18 +03:00
parent 5161df4a77
commit 4bde27915f
24 changed files with 285 additions and 6 deletions
+7 -1
View File
@@ -32,6 +32,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
* @type {GenerateOptions}
*/
private static readonly escodegenParams: escodegen.GenerateOptions = {
comment: true,
verbatim: 'x-verbatim-property',
sourceMapWithCode: true
};
@@ -78,6 +79,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
* @type {NodeTransformer[]}
*/
private static readonly preparingTransformersList: NodeTransformer[] = [
NodeTransformer.CommentsTransformer,
NodeTransformer.ObfuscatingGuardsTransformer,
NodeTransformer.ParentificationTransformer
];
@@ -193,7 +195,11 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
* @returns {Program}
*/
private transformAstTree (astTree: ESTree.Program): ESTree.Program {
if (NodeGuards.isProgramNode(astTree) && !astTree.body.length) {
const isEmptyAstTree: boolean = NodeGuards.isProgramNode(astTree)
&& !astTree.body.length
&& !astTree.leadingComments;
if (isEmptyAstTree) {
this.logger.warn(LoggingMessage.EmptySourceCode);
return astTree;