Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async function() {
await mkdir(path.resolve(`.licia/packages/licia-uglify`));
const _keys = keys(modData);
for (let i = 0, len = _keys.length; i < len; i++) {
const key = _keys[i];
const data = modData[key];
if (!contain(data.env, 'browser') && !contain(data.env, 'miniprogram'))
continue;
const srcPath = path.resolve(`.licia/packages/licia/${key}.js`);
const output = uglifyJs.minify(await fs.readFile(srcPath, 'utf8'));
if (output.error) {
console.log(`Something wrong with ${key}: ${output.error}`);
process.exit(1);
}
const outputPath = path.resolve(
`.licia/packages/licia-uglify/${key}.js`
);
await fs.writeFile(outputPath, output.code, 'utf8');
}
})();
async function genFile(file, pkgName) {
let modName = last(file.split('/')).slice(0, -3);
let data = await fs.readFile(file, 'utf8');
const env = modData[modName].env;
const isEs5 = contain(env, 'browser') || contain(env, 'miniprogram');
if (isEs5 && pkgName !== 'licia-src') {
data = await transBabel(data);
}
if (pkgName === 'miniprogram-licia') {
if (!contain(env, 'miniprogram')) {
return;
}
}
data = data.replace(/\/\* module[\s\S]*?\*\//m, '');
if (pkgName === 'eustia-module') {
await fs.writeFile(
path.resolve('./.licia/packages/' + pkgName, modName + '.js'),
data,
'utf-8'
async function genFile(file, pkgName) {
let modName = last(file.split('/')).slice(0, -3);
let data = await fs.readFile(file, 'utf8');
const env = modData[modName].env;
const isEs5 = contain(env, 'browser') || contain(env, 'miniprogram');
if (isEs5 && pkgName !== 'licia-src') {
data = await transBabel(data);
}
if (pkgName === 'miniprogram-licia') {
if (!contain(env, 'miniprogram')) {
return;
}
}
data = data.replace(/\/\* module[\s\S]*?\*\//m, '');
if (pkgName === 'eustia-module') {
await fs.writeFile(
path.resolve('./.licia/packages/' + pkgName, modName + '.js'),
data,
'utf-8'
);
} else {
const dependencies = extractDependencies(data);
data = transToCommonjs(data, dependencies, isEs5);
module.exports = async function() {
let cmdName = options.remain[0];
if (contain(['benchmark', 'test', 'pack', 'update'], cmdName)) {
await output(cmdName);
} else {
await outputAll();
}
};
} else if (val === 'all') {
val = ['node', 'browser'];
} else {
val = [val];
}
}
ret[name] = val;
});
});
if (!ret['test']) {
const env = ret['env'];
const val = [];
if (contain(env, 'node')) val.push('node');
if (contain(env, 'browser')) val.push('browser');
ret['test'] = val;
}
return ret;
}
}
each(dependencies, (val, i) => {
if (!contain(tsDefinition, val)) return;
imports += 'import ' + val + " = require('./" + val + "');";
if (i !== len - 1) imports += '\n';
});
}