message: test(cli): use mock-fs in tasks
diff: */
  import fs from 'fs-extra';
  +import mockFs from 'mock-fs';
  import { resolve as resolvePath } from 'path';
  -import os from 'os';
  -import del from 'del';
  import { templatingTask } from './tasks';
  describe('templatingTask', () => {
  + afterEach(() => {
  + mockFs.restore();
  + });
  +
  it('should template a directory with mix of regular files and templates', async () => {
  - // Set up a testing template directory
  - const tmplDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'test-'));
  - await fs.ensureDir(resolvePath(tmplDir, 'sub'));
  - await fs.writeFile(resolvePath(tmplDir, 'test.txt'), 'testing');
  - await fs.writeFile(
  - resolvePath(tmplDir, 'sub/version.txt.hbs'),
  - 'version: {{version}}',
  - );
  + // Testing template directory
  + const tmplDir = 'test-tmpl';
  - // Set up a temporary dest dir to write the template to
  - const destDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'test-'));
  + // Temporary dest dir to write the template to
  + const destDir = 'test-dest';
  +
  + mockFs({
  + [tmplDir]: {
  + 'sub': {
  + 'version.txt.hbs': 'version: {{version}}',
  + },
  + 'test.txt': 'testing',
  + },
  + [destDir]: {},
  + });
  - try {
  await templatingTask(tmplDir, destDir, {
  version: '0.0.0',
  });
  @@ -45,9 +51,5 @@ describe('templatingTask', () => {
  await expect(
  fs.readFile(resolvePath(destDir, 'sub/version.txt'), 'utf8'),
  ).resolves.toBe('version: 0.0.0');
  - } finally {
  - await del(tmplDir, { force: true });
  - await del(destDir, { force: true });
  - }
  });
  });
  