How to use smart-fs - 10 common examples

To help you get started, we’ve selected a few smart-fs 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 blackflux / js-gardener / test / subtasks / eslint.spec.js View on Github external
it('Testing reportUnusedDisableDirectives', async ({ dir, capture, recorder }) => {
    const idxFile = path.join(dir, 'src', 'index.js');
    sfs.smartWrite(idxFile, ['// eslint-disable-next-line no-console\nmodule.exports = {};']);
    sfs.smartWrite(path.join(dir, '.eslintrc.json'), { root: true });
    const e = await capture(() => eslint(console, dir, { files: [idxFile] }));
    expect(String(e)).to.equal('Error: Linter Problems');
    const logs = recorder.get();
    expect(logs.length).to.equal(1);
    expect(logs[0]).to.include('Unused eslint-disable directive');
  });
github blackflux / js-gardener / test / subtasks / eslint.spec.js View on Github external
it('Testing Invalid File', async ({ dir, recorder }) => {
    sfs.smartWrite(path.join(dir, 'index.js'), ['module.exports = "string"\n']);
    try {
      await eslint(console, dir, { files: [path.join(dir, 'index.js')] });
    } catch (e) {
      expect(String(e)).to.contain('Error: Linter Problems');
      expect(String(recorder.get())).to.contain('4 problems (3 errors, 1 warning)');
    }
  });
});
github blackflux / js-gardener / test / subtasks / depused.spec.js View on Github external
it('Testing Ok', async ({ dir, recorder }) => {
    sfs.smartWrite(path.join(dir, 'package.json'), {});
    await depused(console, dir, []);
    expect(recorder.get().length).to.equal(0);
  });
github blackflux / js-gardener / test / subtasks / struct.spec.js View on Github external
it('Testing Failure', async ({ dir, capture, recorder }) => {
    sfs.smartWrite(path.join(dir, 'test', 'index.spec.js'), ['']);
    await capture(struct(console, dir, []));
    const logs = recorder.get();
    expect(logs.length).to.equal(1);
    expect(logs[0]).to.contain('index.js to exist for ');
    expect(logs[0]).to.contain('index.spec.js');
  });
});
github blackflux / js-gardener / test / subtasks / depcheck.spec.js View on Github external
it('Testing Ok (YARN)', async ({ dir, recorder }) => {
    sfs.smartWrite(path.join(dir, 'package.json'), { dependencies: { mocha: '5.0.5' }, license: 'MIT' });
    exec.run('yarn install --silent --non-interactive', dir);
    await depcheck(console, dir);
    expect(recorder.get()).to.deep.equal([]);
  });
});
github blackflux / js-gardener / test / subtasks / robo.spec.js View on Github external
it('Testing Update (Failure)', async ({ dir, capture, recorder }) => {
    const result = ['Updated: CONFDOCS.md'];
    sfs.smartWrite(path.join(dir, '.roboconfig.json'), {
      '@blackflux/robo-config-plugin': {
        tasks: [],
        variables: {}
      }
    });
    const e = await capture(() => robo(console, dir));
    expect(e).to.deep.equal(result);
    expect(recorder.get()).to.deep.equal(result);
  });
github blackflux / js-gardener / test / index.spec.js View on Github external
it('Testing Ok', async ({ dir }) => {
    sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
    sfs.smartWrite(
      path.join(dir, '.eslintrc.json'),
      sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
    );
    fs.symlinkSync(
      path.join(__dirname, '..', 'node_modules'),
      path.join(dir, 'node_modules')
    );
    sfs.smartWrite(path.join(dir, 'package.json'), {
      name: 'pkg',
      dependencies: {
        '@babel/register': '1.0.0'
      },
      main: 'index.js'
    });
    expect(await gardener({ cwd: dir })).to.equal(undefined);
github blackflux / js-gardener / test / index.spec.js View on Github external
it('Testing Ok', async ({ dir }) => {
    sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
    sfs.smartWrite(
      path.join(dir, '.eslintrc.json'),
      sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
    );
    fs.symlinkSync(
      path.join(__dirname, '..', 'node_modules'),
      path.join(dir, 'node_modules')
    );
    sfs.smartWrite(path.join(dir, 'package.json'), {
      name: 'pkg',
      dependencies: {
        '@babel/register': '1.0.0'
      },
      main: 'index.js'
    });
    expect(await gardener({ cwd: dir })).to.equal(undefined);
  });
github blackflux / js-gardener / test / subtasks / yamllint.spec.js View on Github external
it('Testing Ok', async ({ dir }) => {
    sfs.smartWrite(path.join(dir, 'valid.yml'), ['double']);
    await yamllint(console, dir, ['valid.yml']);
  });
github blackflux / js-gardener / test / index.spec.js View on Github external
it('Testing Ok', async ({ dir }) => {
    sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
    sfs.smartWrite(
      path.join(dir, '.eslintrc.json'),
      sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
    );
    fs.symlinkSync(
      path.join(__dirname, '..', 'node_modules'),
      path.join(dir, 'node_modules')
    );
    sfs.smartWrite(path.join(dir, 'package.json'), {
      name: 'pkg',
      dependencies: {
        '@babel/register': '1.0.0'
      },
      main: 'index.js'
    });
    expect(await gardener({ cwd: dir })).to.equal(undefined);
  });

smart-fs

Abstraction Layer for File Management.

MIT
Latest version published 9 months ago

Package Health Score

47 / 100
Full package analysis

Popular smart-fs functions