How to use the licia.contain function in licia

To help you get started, we’ve selected a few licia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liriliri / licia / lib / es5.js View on Github external
(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');
    }
})();
github liriliri / licia / lib / pack.js View on Github external
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'
github liriliri / licia / lib / pack.js View on Github external
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);
github liriliri / licia / lib / help.js View on Github external
module.exports = async function() {
    let cmdName = options.remain[0];
    if (contain(['benchmark', 'test', 'pack', 'update'], cmdName)) {
        await output(cmdName);
    } else {
        await outputAll();
    }
};
github liriliri / licia / lib / update.js View on Github external
} 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;
    }
}
github liriliri / licia / lib / pack.js View on Github external
each(dependencies, (val, i) => {
            if (!contain(tsDefinition, val)) return;

            imports += 'import ' + val + " = require('./" + val + "');";

            if (i !== len - 1) imports += '\n';
        });
    }