How to use make-dir - 10 common examples

To help you get started, we’ve selected a few make-dir 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 istanbuljs / istanbuljs / packages / istanbul-api / lib / run-instrument.js View on Github external
if (iOpts.completeCopy()) {
        includes = ['**/*'];
    } else {
        includes = iOpts.extensions().map(ext => '**/*' + ext);
    }

    if (!input) {
        return callback(new Error('No input specified'));
    }

    instrumenter = libInstrument.createInstrumenter(
        iOpts.getInstrumenterOpts()
    );

    if (needBaseline) {
        mkdirp.sync(path.dirname(baselineFile));
        instrumenter = new BaselineCollector(instrumenter);
        callback = function(err) {
            /* istanbul ignore else */
            if (!err) {
                console.error('Saving baseline coverage at ' + baselineFile);
                fs.writeFileSync(
                    baselineFile,
                    JSON.stringify(instrumenter.getCoverage()),
                    'utf8'
                );
            }
            return origCallback(err);
        };
    }

    const file = path.resolve(input);
github prisma / photonjs / packages / photon / src / generation / generateClient.ts View on Github external
datamodel,
    datamodelPath,
    schemaDir,
    transpile,
    runtimePath,
    browser,
    outputDir,
    generator,
    version,
    dmmf,
    datasources,
    binaryPaths,
  })

  debug(`makeDir: ${outputDir}`)
  await makeDir(outputDir)
  await Promise.all(
    Object.entries(fileMap).map(async ([fileName, file]) => {
      const filePath = path.join(outputDir, fileName)
      // The deletion of the file is necessary, so VSCode
      // picks up the changes.
      if (await exists(filePath)) {
        await remove(filePath)
      }
      await writeFile(filePath, file)
    }),
  )
  const inputDir = testMode
    ? eval(`require('path').join(__dirname, '../../runtime')`) // tslint:disable-line
    : eval(`require('path').join(__dirname, '../runtime')`) // tslint:disable-line

  // if users use a custom output dir
github DevExpress / testcafe / src / utils / temp-directory / index.js View on Github external
async _createNewTmpDir () {
        this.path = tmp.tmpNameSync({ dir: TempDirectory.TEMP_DIRECTORIES_ROOT, prefix: this.namePrefix + '-' });

        await makeDir(this.path);

        this.lockFile = new LockFile(this.path);

        this.lockFile.init();
    }
github vmware / clarity / latest / prerender.ts View on Github external
].forEach(file => {
    const content = ``;
    if (!existsSync(file.from)) {
      makeDir.sync(file.from);
    }
    writeFileSync(join(file.from, 'index.html'), content);
  });
};
github DevExpress / testcafe / src / runner / bootstrapper.js View on Github external
async _ensureOutStream (outStream) {
        if (typeof outStream !== 'string')
            return outStream;

        const fullReporterOutputPath = resolvePathRelativelyCwd(outStream);

        await makeDir(path.dirname(fullReporterOutputPath));

        return fs.createWriteStream(fullReporterOutputPath);
    }
github zeit / next.js / packages / create-next-app / create-app.ts View on Github external
if (example) {
    const found = await hasExample(example)
    if (!found) {
      console.error(
        `Could not locate an example named ${chalk.red(
          `"${example}"`
        )}. Please check your spelling and try again.`
      )
      process.exit(1)
    }
  }

  const root = path.resolve(appPath)
  const appName = path.basename(root)

  await makeDir(root)
  if (!isFolderEmpty(root, appName)) {
    process.exit(1)
  }

  const useYarn = useNpm ? false : shouldUseYarn()
  const isOnline = !useYarn || (await getOnline())
  const originalDirectory = process.cwd()

  const displayedCommand = useYarn ? 'yarn' : 'npm'
  console.log(`Creating a new Next.js app in ${chalk.green(root)}.`)
  console.log()

  await makeDir(root)
  process.chdir(root)

  if (example) {
github babel / babel / packages / babel-cli / src / babel / dir.js View on Github external
return count;
    } else {
      const filename = filenameOrDir;
      const written = await handleFile(filename, path.dirname(filename));

      return written ? 1 : 0;
    }
  }

  if (!cliOptions.skipInitialBuild) {
    if (cliOptions.deleteDirOnStart) {
      util.deleteDir(cliOptions.outDir);
    }

    makeDirSync(cliOptions.outDir);

    let compiledFiles = 0;
    for (const filename of cliOptions.filenames) {
      compiledFiles += await handle(filename);
    }

    if (!cliOptions.quiet) {
      console.log(
        `Successfully compiled ${compiledFiles} ${
          compiledFiles !== 1 ? "files" : "file"
        } with Babel.`,
      );
    }
  }

  if (cliOptions.watch) {
github splunk / splunk-sdk-javascript / node_modules / nyc / index.js View on Github external
const visitor = relFile => {
      const inFile = path.resolve(inputDir, relFile)
      const inCode = fs.readFileSync(inFile, 'utf-8')
      const outCode = this._transform(inCode, inFile) || inCode

      if (output) {
        const mode = fs.statSync(inFile).mode
        const outFile = path.resolve(output, relFile)
        mkdirp.sync(path.dirname(outFile))
        fs.writeFileSync(outFile, outCode)
        fs.chmodSync(outFile, mode)
      } else {
        console.log(outCode)
      }
    }
github splunk / splunk-sdk-javascript / node_modules / nyc / index.js View on Github external
createTempDirectory () {
    mkdirp.sync(this.tempDirectory())
    if (this.cache) mkdirp.sync(this.cacheDirectory)

    mkdirp.sync(this.processInfoDirectory())
  }
github babel / babel / packages / babel-cli / src / babel / dir.js View on Github external
function outputFileSync(filePath: string, data: string | Buffer): void {
  makeDirSync(path.dirname(filePath));
  fs.writeFileSync(filePath, data);
}

make-dir

Make a directory and its parents if needed - Think `mkdir -p`

MIT
Latest version published 7 months ago

Package Health Score

76 / 100
Full package analysis

Popular make-dir functions