All files / src/commands common.js

55.56% Statements 5/9
100% Branches 0/0
33.33% Functions 2/6
55.56% Lines 5/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                  21x                           21x       25x       25x       21x            
import {join} from 'path';
import {mkdirp} from 'fs-extra';
import {
    PackageJsonEditor,
    Scaffolder,
    allDoNotExist
} from '../api';
 
/** @ignore */
export const createEditorConfiguration = [
    {
        text: 'Create editor configuration file',
        task: async ({overwrite}) => {
            await (new Scaffolder(join(__dirname, 'common', 'templates')))
                .overwrite(overwrite)
                .target('.')
                .copy('.editorconfig', '.editorconfig')
                .commit();
        },
        condition: () => allDoNotExist('.editorconfig')
    }
];
/** @ignore */
export const createPackageJson = [
    {
        text: 'Create package.json',
        task: async () => {
            await (new PackageJsonEditor())
                .create()
                .commit();
        },
        condition: () => allDoNotExist('package.json')
    }
];
/** @ignore */
export const createSourceDirectory = [
    {
        text: 'Create source directory',
        task: ({sourceDirectory}) => mkdirp(sourceDirectory),
        condition: ({sourceDirectory}) => allDoNotExist(sourceDirectory)
    }
];