How to use the tmp.tmpName function in tmp

To help you get started, we’ve selected a few tmp 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 argos-ci / image-difference / lib / image-diff.js View on Github external
function resizeExpectedImage (cb) {
            tmp.tmpName({postfix: '.png'}, function (err, filepath) {
              // If there was an error, callback
              if (err) {
                return cb(err);
              }

              // If there was no expected image, create a transparent image to compare against
              expectedTmpPath = filepath;
              if (expectedSize.doesNotExist) {
                gm(maxWidth, maxHeight, 'transparent').write(expectedTmpPath, cb);
              // Otherwise, resize the image
              } else {
                transparentExtent(gm(expectedPath), {
                  width: maxWidth,
                  height: maxHeight
                }).write(expectedTmpPath, cb);
              }
github argos-ci / image-difference / lib / image-diff.js View on Github external
function resizeActualImage (cb) {
            // Get a temporary filepath
            tmp.tmpName({postfix: '.png'}, function (err, filepath) {
              // If there was an error, callback
              if (err) {
                return cb(err);
              }

              // Otherwise, resize the image
              actualTmpPath = filepath;
              transparentExtent(gm(actualPath), {
                width: maxWidth,
                height: maxHeight
              }).write(actualTmpPath, cb);
            });
          },
          function resizeExpectedImage (cb) {
github theia-ide / extension-registry / cli / src / util.ts View on Github external
return new Promise((resolve, reject) => {
        tmp.tmpName(options, (err, name) => {
            if (err)
                reject(err);
            else
                resolve(name);
        });
    });
}
github bevacqua / ponymark / src / node.js View on Github external
function (next) {
      tmp.tmpName({ template: template }, next);
    },
    function (temp, next) {
github TypeStrong / atom-typescript / node_modules / atom-package-dependencies / index.js View on Github external
function grepAsync(regex, text, callback){
  var tmp = require('tmp');
  tmp.tmpName(function _tempNameGenerated(err, path) {
    if (err) throw err;
    fs.writeFileSync(path, text);
    var result = sh.grep(regex, path);
    callback(result);
  });
}
github eez-open / studio / packages / eez-studio-shared / util-electron.ts View on Github external
return new Promise((resolve, reject) => {
        const tmp = require("tmp");
        tmp.tmpName(options, function(err: any, path: string) {
            if (err) {
                reject(err);
            } else {
                resolve(path);
            }
        });
    });
}
github mkloubert / vscode-helpers / lib / fs / index.js View on Github external
}
            completedInvoked = true;
            try {
                if (err) {
                    reject(err);
                }
                else {
                    resolve(result);
                }
            }
            finally {
                tryUnlinkTempFile(tempFile, opts);
            }
        };
        try {
            TMP.tmpName(toTmpSimpleOptions(opts), (err, path) => {
                if (err) {
                    COMPLETED(err);
                }
                else {
                    tempFile = path;
                    try {
                        Promise.resolve(action(tempFile)).then((result) => {
                            COMPLETED(null, result);
                        }).catch((e) => {
                            COMPLETED(e);
                        });
                    }
                    catch (e) {
                        COMPLETED(e);
                    }
                }
github travs / atom-package-dependencies / index.js View on Github external
function grepAsync(regex, text, callback){
  var tmp = require('tmp');
  tmp.tmpName(function _tempNameGenerated(err, path) {
    if (err) throw err;
    fs.writeFileSync(path, text);
    var result = sh.grep(regex, path);
    callback(result);
  });
}
github greggman / ffmpegserver.js / lib / utils.js View on Github external
return new Promise(function(fulfill, reject) {
    tmp.tmpName(options, function(err, filePath) {
      if (err) {
        reject(err);
      } else {
        fulfill(filePath);
      }
    });
  });
};
github nteract / nteract / src / notebook / utils.js View on Github external
return new Promise((resolve, reject) => {
    const readStream = fs.createReadStream(filename);
    readStream.on('error', reject);

    const base = path.basename(filename, '.ipynb');

    tmp.tmpName({ prefix: `${base}-Copy`, postfix: '.ipynb' }, (err, newFilename) => {
      if (err) {
        reject(err);
      }

      const writeStream = fs.createWriteStream(newFilename);
      writeStream.on('error', reject);

      readStream.pipe(writeStream);
      writeStream.on('close', resolve(newFilename));
    });
  });
}