How to use the licia.fs.exists 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 / update.js View on Github external
async function genI18n() {
    let doc = await fs.readFile(OUTPUT_DOC_PATH, 'utf8');
    doc = splitH2(doc);

    const i18n = {};

    for (let i = 0, len = doc.length; i < len; i++) {
        const name = doc[i].name;
        const i18nPath =
            'src/' + name[0].toLowerCase() + '/' + name + '.i18n.md';
        if (await fs.exists(i18nPath)) {
            let doc = await fs.readFile(i18nPath, 'utf8');
            let code = await fs.readFile(
                i18nPath.replace('.i18n.md', '.js'),
                'utf8'
            );
            let comments = extractBlockCmts(code);
            let example = '';
            comments.forEach(comment => {
                comment = trim(comment);
                if (startWith(comment, 'example')) {
                    example = comment.replace(/^example/, '');
                    example = outdentOneSpace(example);
                    example = example.replace(regTsIgnore, '');
                    example = '```javascript\n' + trim(example) + '\n```';
                }
            });
github liriliri / licia / lib / util.js View on Github external
exports.fileExist = async function(path) {
    const exist = await fs.exists(path);
    if (!exist) throw Error(path + ' does not exist.');
};