fs-extra#removeSync TypeScript Examples

The following examples show how to use fs-extra#removeSync. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: tsc.ts    From multi-downloader-nx with MIT License 5 votes vote down vote up
(async () => {

  const waitForProcess = async (proc: ChildProcess) => {
    return new Promise((resolve, reject) => {
      proc.stdout?.on('data', console.log);
      proc.stderr?.on('data', console.error);
      proc.on('close', resolve);
      proc.on('error', reject);
    });
  };

  process.stdout.write('Removing lib dir... ');
  removeSync('lib');
  process.stdout.write('✓\nRunning tsc... ');
  const tsc = exec('npx tsc');

  await waitForProcess(tsc);
  
  if (!isGUI) {
    fs.emptyDirSync(path.join('lib', 'gui'));
    fs.rmdirSync(path.join('lib', 'gui'));
  }

  if (!isTest && isGUI) {
    process.stdout.write('✓\nBuilding react... ');

    const installReactDependencies = exec('npm install', {
      cwd: path.join(__dirname, 'gui', 'react'),
    });

    await waitForProcess(installReactDependencies);
  
    const react = exec('npm run build', {
      cwd: path.join(__dirname, 'gui', 'react'),
    });
  
    await waitForProcess(react);
  }

  process.stdout.write('✓\nCopying files... ');
  if (!isTest && isGUI) {
    copyDir(path.join(__dirname, 'gui', 'react', 'build'), path.join(__dirname, 'lib', 'gui', 'electron', 'build'));
  }

  const files = readDir(__dirname);
  files.forEach(item => {
    const itemPath = path.join(__dirname, 'lib', item.path.replace(__dirname, ''));
    if (item.stats.isDirectory()) {
      if (!fs.existsSync(itemPath))
        fs.mkdirSync(itemPath);
    } else {
      copyFileSync(item.path, itemPath);
    }
  });

  process.stdout.write('✓\nInstalling dependencies... ');
  if (!isTest && !isGUI) {
    alterJSON();
  }
  if (!isTest) {
    const dependencies = exec(`npm install ${isGUI ? '' : '--production'}`, {
      cwd: path.join(__dirname, 'lib')
    });
    await waitForProcess(dependencies);
  }

  process.stdout.write('✓\n');
})();
Example #2
Source File: clean.ts    From DefinitelyTyped-tools with MIT License 5 votes vote down vote up
export function clean() {
  removeSync(dataDirPath);
}
Example #3
Source File: clean.ts    From DefinitelyTyped-tools with MIT License 5 votes vote down vote up
export function clean() {
  cleanParser();
  cleanLogDirectory();
  removeSync(outputDirPath);
  removeSync(validateOutputPath);
}
Example #4
Source File: logging.ts    From DefinitelyTyped-tools with MIT License 5 votes vote down vote up
export function cleanLogDirectory() {
  removeSync(logDir);
}
Example #5
Source File: index.ts    From nx-dotnet with MIT License 5 votes vote down vote up
// Useful in order to cleanup space during CI to prevent `No space left on device` exceptions
export function removeProject({ onlyOnCI = false } = {}) {
  if (onlyOnCI && !isCI) {
    return;
  }
  removeSync(tmpProjPath());
}
Example #6
Source File: index.ts    From nx-dotnet with MIT License 5 votes vote down vote up
export function rmDist() {
  removeSync(`${tmpProjPath()}/dist`);
}
Example #7
Source File: e2e.ts    From nx-dotnet with MIT License 5 votes vote down vote up
async function runTest() {
  let selectedProjects = process.argv[2];

  let testNamePattern = '';
  if (process.argv[3] === '-t' || process.argv[3] === '--testNamePattern') {
    testNamePattern = `--testNamePattern "${process.argv[4]}"`;
  }

  if (process.argv[3] === 'affected') {
    const affected = execSync(
      `npx nx print-affected --base=origin/master --select=projects`,
    )
      .toString()
      .split(',')
      .map((s) => s.trim())
      .filter((s) => s.length > 0);
    selectedProjects =
      affected.length === 0
        ? selectedProjects
        : selectedProjects
            .split(',')
            .filter((s) => affected.indexOf(s) > -1)
            .join(',');
  }

  if (process.argv[5] != '--rerun') {
    removeSync('./dist');
    removeSync(tmpProjPath());
  }

  try {
    await setup();
    if (selectedProjects === '') {
      console.log('No tests to run');
    } else if (selectedProjects) {
      execSync(
        selectedProjects.split(',').length > 1
          ? `yarn nx run-many --target=e2e --projects=${selectedProjects} ${testNamePattern}`
          : `yarn nx run ${selectedProjects}:e2e ${testNamePattern}`,
        {
          stdio: [0, 1, 2],
          env: {
            ...process.env,
            NX_CLOUD_DISTRIBUTED_EXECUTION: 'false',
            NX_TERMINAL_CAPTURE_STDERR: 'true',
            NPM_CONFIG_REGISTRY: 'http://localhost:4872',
            YARN_REGISTRY: 'http://localhost:4872',
          },
        },
      );
    } else {
      execSync(`yarn nx run-many --target=e2e --all`, {
        stdio: [0, 1, 2],
        env: {
          ...process.env,
          NX_CLOUD_DISTRIBUTED_EXECUTION: 'false',
          NX_TERMINAL_CAPTURE_STDERR: 'true',
          NPM_CONFIG_REGISTRY: 'http://localhost:4872',
          YARN_REGISTRY: 'http://localhost:4872',
        },
      });
    }
    cleanUp(0);
  } catch (e) {
    console.log(e);
    cleanUp(1);
  }
}
Example #8
Source File: setup.ts    From nx-dotnet with MIT License 5 votes vote down vote up
export function cleanupVerdaccioData() {
  killVerdaccioInstance();
  // Remove previous packages with the same version
  // before publishing the new ones
  removeSync(join(__dirname, '../../../tmp/local-registry'));
}
Example #9
Source File: quick-start.ts    From electron-playground with MIT License 5 votes vote down vote up
removeSync(dist)