Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readdirSync(dir).sort().forEach(function (filename) {
var file = path.join(dir, filename),
stat = fs.statSync(file);
if (stat.isDirectory()) {
walk(file, isTitaniumFolder || filename == 'titanium');
} else if (/\.js$/.test(filename)) {
self.logger.debug(self.minifyJS ? __('Minifying %s', file.cyan) : __('Analyzing %s', file.cyan));
try {
var r = jsanalyze.analyzeJsFile(file, { minify: self.minifyJS, skipStats: isTitaniumFolder || file == tiJSFile });
self.minifyJS && fs.writeFileSync(file, r.contents);
} catch (ex) {
ex.message.split('\n').forEach(self.logger.error);
self.logger.log();
process.exit(1);
}
}
});
}(this.buildDir));
if (!requireCacheWritten) {
tiJS += 'require.cache({\n';
requireCacheWritten = true;
}
if (!first) {
tiJS += ',\n';
}
first = false;
moduleCounter++;
var file = path.join(dep[0], /\.js$/.test(dep[1]) ? dep[1] : dep[1] + '.js'),
r;
try {
r = jsanalyze.analyzeJsFile(file, { minify: /^url\:/.test(moduleName) && this.minifyJS, skipStats: file == tiJSFile || file.indexOf(tiDir) == 0 });
} catch (ex) {
ex.message.split('\n').forEach(this.logger.error);
this.logger.log();
process.exit(1);
}
if (/^url\:/.test(moduleName)) {
if (this.minifyJS) {
this.logger.debug(__('Minifying include %s', file.cyan));
try {
fs.writeFileSync(file, r.contents);
} catch (ex) {
this.logger.error(__('Failed to minify %s', file));
if (ex.line) {
this.logger.error(__('%s [line %s, column %s]', ex.message, ex.line, ex.col));
} else {
this.jsFilesToEncrypt.forEach(function (file) {
const r = jsanalyze.analyzeJsFile(file, { minify: true });
this.tiSymbols[file] = r.symbols;
this.metaData.push.apply(this.metaData, r.symbols);
}.bind(this));