How to use the mkdirp function in mkdirp

To help you get started, we’ve selected a few mkdirp 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 wxajs / wxa / packages / wxa-compiler-babel / src / fs-cache.js View on Github external
return new Promise((resolve, reject)=>{
        const {source, options={}, transform, identifier} = params;
        const shouldFallback = typeof params.directory !== 'string' && directory !== os.tmpdir();

        mkdirp(directory, (err)=>{
            if (err) shouldFallback ? handleCache(os.tmpdir(), params) : reject(err);

            const file = path.join(directory, filename(source, identifier, options));

            read(file).then((succ)=>{
                // cached file
                resolve(succ);
            }, (fail)=>{
                // transform source
                try {
                    params.transform(source, options).then((ret)=>{
                        write(file, ret).then((succ)=>{
                            resolve(ret);
                        }, (fail)=>{
                            if (!shouldFallback) {
                                reject(fail);
github ttag-org / babel-plugin-ttag / tests / functional / test_resolve_ngettext.js View on Github external
it('should use proper plural form', () => {
        rmDirSync('debug');
        mkdirp('debug');
        const resultPath = 'debug/ngettext_result.js';
        const input = 'const n = parseInt(process.env.TEST_N, 10);\n' +
            'process.stdout.write(ngettext(msgid`plural form with ${ n } plural`, ' +
            '`plural form with ${ n } plurals`, n));';
        const result = babel.transform(input, options).code;
        fs.writeFileSync(resultPath, result, { mode: 0o777 });

        const { stdout: stdout1 } = childProcess.spawnSync('node', [resultPath],
            { env: Object.assign(process.env, { TEST_N: 1 }) });
        expect(stdout1.toString()).to.eql('plural form with 1 plural [translated]');
        const { stdout: stdout2 } = childProcess.spawnSync('node', [resultPath],
            { env: Object.assign(process.env, { TEST_N: 2 }) });
        expect(stdout2.toString()).to.eql('plural form with 2 plurals [translated]');
    });
github northbrookjs / northbrook / src / plugin / link.js View on Github external
packagesToSymlink.forEach(function (pkg) {
    const srcDir = join(workingDir, pkg)
    const srcName = require(join(srcDir, 'package.json')).name
    const destinationDir = join(nodeDir, pkg)

    if (isLink(destinationDir)) {
      return log('symlinks for', symlinkToName, 'already exist...')
    }

    mkdirp(nodeDir, function (err) {
      if (err) throw err

      if (isScoped(srcName)) {
        const [scope, name] = srcName.split('/')

        mkdirp(join(nodeDir, scope), function (err) {
          if (err) throw err

          const dest = join(nodeDir, scope, name)

          if (exists(dest)) {
            return log('  ', srcName, 'already exists')
          }

          symlinkSync(srcDir, dest)
        })
github lukekarrys / instagram-download / src / util / saveFiles.js View on Github external
writeIfNeeded(() => {
    mkdirp(dirname, (err) => {
      if (err) {
        debugMedia(`Error creating dir ${dirname}: ${err}`)
        return saveDoneOnce(err)
      }
      request(url)
      .on('error', (err) => {
        debugMedia(`Error fetching media ${url}: ${err}`)
        saveDoneOnce(err)
      })
      .pipe(fs.createWriteStream(filepath))
      .on('close', saveDoneOnce)
    })
  })
}
github darlanmendonca / generator-bitch / app / generator.js View on Github external
function sources() {
  mkdirp('sources/imgs')
  mkdirp('sources/styles/components')
  mkdirp('sources/sprites')
  if (this.appFramework !== 'none') {
    mkdirp(`sources/${this.appFramework}`)
  }
}
github elastic / generator-kibana-plugin / generators / app / templates / gulpfile.babel.js View on Github external
function syncPluginTo(dest, done) {
  mkdirp(dest, function (err) {
    if (err) return done(err);

    const source = path.resolve(__dirname) + '/';
    const rsync = new Rsync();

    rsync.source(source)
    .destination(dest)
    .flags('uav')
    .recursive(true)
    .set('delete')
    .include(include)
    .exclude(exclude)
    .output(function (data) {
      process.stdout.write(data.toString('utf8'));
    });
github SamyPesse / gitkit-js / src / fs / NodeFS.js View on Github external
return new Promise((resolve, reject) => {
            mkdirp(
                dirpath,
                {
                    fs: this.fs
                },
                err => {
                    if (err) {
                        reject(err);
                    } else {
                        resolve();
                    }
                }
            );
        });
    }
github wisnuc / appifi / src / fruitmix / lib / shareStore.js View on Github external
mkdirp(arcdir, err => {
      if(err) return callback(err)
      mkdirp(tmpdir, err => {
        if(err) return callback(err)
        callback(null, new ShareStore(rootdir, arcdir, tmpdir, docstore))
      })
    })
  })
github HuijiFE / void-ui / packages / docs / scripts / gen-pages.ts View on Github external
fs.exists(dir, exists => {
            if (exists) {
              fs.copyFile(indexPath, path, cpError =>
                cpError ? reject(cpError) : resolve(),
              );
            } else {
              mkdirp(dir, mkError =>
                mkError
                  ? reject(mkError)
                  : fs.copyFile(indexPath, path, cpError =>
                      cpError ? reject(cpError) : resolve(),
                    ),
              );
            }
          });
        }),
github chenryn / kbn_sankey_vis / gulpfile.babel.js View on Github external
function syncPluginTo(dest, done) {
  mkdirp(dest, function (err) {
    if (err) return done(err);

    const source = path.resolve(__dirname) + '/';
    const rsync = new Rsync();

    rsync.source(source)
    .destination(dest)
    .flags('uav')
    .recursive(true)
    .set('delete')
    .include(include)
    .exclude(exclude)
    .output(function (data) {
      process.stdout.write(data.toString('utf8'));
    });

mkdirp

Recursively mkdir, like `mkdir -p`

MIT
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis