How to use the mkdirp.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 mosen / buildy / lib / buildy / tasks / write.js View on Github external
this.state.forEach(function(name, value) {
            var basename; // filename without path.

            if (value.file) {
                basename = task_parameters.fnRename(path.basename(value.file), task_parameters.prefix, task_parameters.suffix);
            } else {
                basename = task_parameters.fnRename(name, task_parameters.prefix, task_parameters.suffix);
            }

            if (!fs.existsSync(path.dirname(task_parameters.dest))) {
                var self = this;

                mkdirp(path.dirname(task_parameters.dest), function(err) {
                    self.state.write(path.join(task_parameters.dest, basename), value, function(err) {
                        if (err) {
                            return status.emit('failure', 'write', 'Could not write: ' + err);
                        }

                        if (!--todo) {
                            return status.emit('complete', 'write', 'Items written.');
                        }
                    }, self);
                });
            } else {
                var self = this;

                self.state.write(path.join(task_parameters.dest, basename), value, function(err) {
                    if (err) {
                        return status.emit('failure', 'write', 'Could not write: ' + err);
github acoustic-content-samples / wchtools-cli / authoring-api / lib / assetsFS.js View on Github external
_getItemWriteStream (context, filepath, opts) {
        const deferred = Q.defer();

        // Create any directories specified in the file's path.
        mkdirp.mkdirp(path.dirname(filepath), function (err) {
            if (err) {
                // Reject the promise if an error occurs when creating a directory.
                deferred.reject(err);
            } else {
                try {
                    // Resolve the promise with a write stream for the specified local file.
                    const stream = fs.createWriteStream(filepath);
                    deferred.resolve(stream);
                } catch (err) {
                    // Reject the promise if an error occurs when creating the stream.
                    deferred.reject(err);
                }
            }
        });

        return deferred.promise;
github acoustic-content-samples / wchtools-cli / authoring-api / lib / assetsFS.js View on Github external
getItemWriteStream (context, asset, opts) {
        const deferred = Q.defer();
        const self = this;

        // Get the file path for the destination file, creating the working directory if necessary.
        const filepath = this.getPath(context, opts) + this.getAssetPath(asset);
        mkdirp.mkdirp(path.dirname(filepath), function (err) {
            if (err) {
                // Reject the promise if an error occurs when creating a directory.
                deferred.reject(err);
            } else {
                // Get the file path for a temporary file based on the resource ID.
                const tmppath = self.getPath(context, opts) + asset.resource;
                self._getItemWriteStream(context, tmppath, opts)
                    .then(function (stream) {
                        stream.on("finish", function () {
                            // On successful finish, we rename the temporary file to the destination file.
                            try {
                                fs.renameSync(tmppath, filepath);
                            } catch (err) {
                                utils.logErrors(context, i18n.__("error_resource_rename", {"temp": tmppath, "name": filepath}), err);
                            }
                        });
github jamesshore / object_playground / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }

      options.exists = true;
      testSocket();
    });
  }
github polakowo / datadocs / website / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }

      options.exists = true;
      testSocket();
    });
  }
github sx1989827 / DOClever / Desktop / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }

      options.exists = true;
      testSocket();
    });
  }
github jamesshore / automatopia / node_modules / http-server / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }
      
      options.exists = true;
      testSocket();
    });
  }
github tamb / domponent / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }

      options.exists = true;
      testSocket();
    });
  }
github microsoft / PowerBI-JavaScript / demo / node_modules / portfinder / lib / portfinder.js View on Github external
function createAndTestSocket (dir) {
    mkdirp(dir, options.mod, function (err) {
      if (err) {
        return callback(err);
      }

      options.exists = true;
      testSocket();
    });
  }

mkdirp

Recursively mkdir, like `mkdir -p`

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis