Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
}
}
if (file === null) {
file = new File({
cwd: options.cwd,
path: path.join(options.cwd, filename)
});
}
file.contents = buffer;
self.push(file);
};
jScrambler.protectAndDownload(options, dest).then(function (protectionId) {
self.emit('protectionId', protectionId);
done(null);
}).catch(function (error) {
// need to emit in nextTick to avoid the promise catching a re-thrown error
process.nextTick(done, error);
});
};
return through.obj(aggregate, scramble);
if (this.excludes.match(filename.slice(0, -4) + '.js')) {
// ensure .map files for excldue JS paths are also copied forward
symlinkOrCopy.sync(inFile, outFile);
}
// skip, because it will get handled when its corresponding JS does
} else {
symlinkOrCopy.sync(inFile, outFile);
}
});
return res;
}, []);
const output = [];
return jscrambler
.protectAndDownload(
Object.assign({}, this.options.jscrambler, {
sources,
stream: false,
clientId: 5
}),
outputFiles => {
outputFiles.forEach(file => {
if (file.filename.slice(-4) !== '.map') {
fs.writeFileSync(
path.join(this.outputPath, file.filename),
file.content
);
}
});
if (sourceMaps && /\.(js.map)$/.test(filename)) {
const sourceMapContent = compilation.assets[filename].source();
if (sourceMapContent) {
sources.push({
content: sourceMapContent,
filename
});
}
}
});
});
if (sources.length > 0) {
Promise.resolve(
client.protectAndDownload(
Object.assign(this.options, {
sources,
stream: false
}),
res => {
this.protectionResult = res;
}
)
)
.then(protectionId =>
this.processResult(protectionId, compilation, callback)
)
.catch(err => {
callback(err);
});
} else {
.then(() => {
config.filesSrc = [`${JSCRAMBLER_SRC_TEMP_FOLDER}/**/*.js`];
config.filesDest = JSCRAMBLER_DIST_TEMP_FOLDER;
config.cwd = JSCRAMBLER_SRC_TEMP_FOLDER;
return jscrambler.protectAndDownload(config);
})
.then(protectionId =>
function writeFile(buffer, file) {
files.forEach(function (elem) {
elem.src.forEach(function (src) {
if(process.platform !== 'win32' && grunt.file.isPathAbsolute(src)) {
var parsedPath = path.parse(src);
src = src.replace(parsedPath.root, '');
}
if(grunt.file.arePathsEquivalent(src, file)) {
grunt.file.write(elem.dest, buffer);
}
});
});
}
jscrambler
.protectAndDownload(options, writeFile)
.then(done)
.catch(function (err) {
grunt.fail.fatal(util.inspect(err));
});
});
};