How to use the tmp.file 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 SeleniumHQ / selenium / javascript / node / selenium-webdriver / io / index.js View on Github external
return checkedCall(callback => {
    // |tmp.file| checks arguments length to detect options rather than doing a
    // truthy check, so we must only pass options if there are some to pass.
    if (opt_options) {
      tmp.file(opt_options, callback);
    } else {
      tmp.file(callback);
    }
  });
};
github chilts / node-awssum-scripts / amazon / s3-sync-down.js View on Github external
function downloadItem(item, callback) {
    var options = {
        BucketName : argv.bucket,
        ObjectName : item.Key,
    };

    fmt.field('Downloading', item.Key);

    tmp.file({ template : '/tmp/tmp-XXXXXXXX.' + process.pid }, function(err, tmpfile, fd) {
        if ( err ) {
            fmt.field('TmpFileError', err);
            callback();
            return;
        }

        // now download the item
        s3.GetObject(options, function(err, data) {
            if (err) {
                fmt.field('ErrorDownloading', err);
                callback();
                return;
            }

            fs.write(fd, data.Body, 0, data.Body.length, 0, function(err, written, buffer) {
                if ( err ) {
github IBM / kui / plugins / plugin-openwhisk-editor-extensions / src / lib / cmds / compose.ts View on Github external
new Promise((resolve, reject) => {
        require('tmp').file({ prefix: 'shell-', postfix }, (err, filepath) => {
          if (err) {
            console.error(err)
            reject(err)
          } else {
            resolve(filepath)
          }
        })
      })
    const write = source =>
github facebookarchive / atom-ide-ui / modules / atom-ide-debugger-python / VendorLib / vs-py-debugger / out / client / common / helpers.js View on Github external
return new Promise((resolve, reject) => {
        tmp.file(options, (err, tmpFile, fd, cleanupCallback) => {
            if (err) {
                return reject(err);
            }
            resolve({ filePath: tmpFile, cleanupCallback: cleanupCallback });
        });
    });
}
github wdullaer / raml2slate / lib / tmp-promise.js View on Github external
return new Promise((resolve, reject) => {
    tmp.file(opts || {}, (err, path, fd, cleanup) => {
      if (err) return reject(err)
      resolve({path, fd, cleanup})
    })
  })
}
github Tustin / PlayStationDiscord / src / Asar / FileSystem.ts View on Github external
if (process.platform !== 'win32' && (file.stat.mode & 0o100))
			{
				node.executable = true;
			}

			this.offset.add(long(size));

			return callback();
		};

		const tr = options.transform && options.transform(p);

		if (tr)
		{
			return tmp.file((err: any, newPath: string) => {
				if (err)
				{
					return handler();
				}

				const out = fs.createWriteStream(newPath);
				const stream = fs.createReadStream(p);

				stream.pipe(tr).pipe(out);

				return out.on('close', () => {
					fs.lstat(newPath, (lstatErr: any, stat: fs.Stats) => {
						if (lstatErr)
						{
							throw new Error(lstatErr);
						}
github IonicaBizau / image-to-ascii / lib / util / index.js View on Github external
Util.createTempFile = function (fileExtension, callback) {
    Tmp.file({postfix: "." + fileExtension}, callback);
};
github redhat-developer / vscode-rsp-ui / src / serverEditorAdapter.ts View on Github external
private async createTmpFile(rspExists: boolean, rspId: string, content: Protocol.GetServerJsonResponse): Promise {
        return tmp.file({ prefix: `${this.PREFIX_TMP}-${content.serverHandle.id}-` , postfix: '.json' }, (err, path) => {
            if (err) {
                return Promise.reject('Could not handle server response. Unable to create temp file');
            }
            if (rspExists) {
                this.RSPServerProperties.get(rspId).push({ server: content.serverHandle.id, file: path});
            } else {
                this.RSPServerProperties.set(rspId, [{ server: content.serverHandle.id, file: path}]);
            }
            this.saveAndShowEditor(path, content.serverJson);
        });
    }
github IBM / taxinomitis / serverless-functions / mltraining-images / src / Downloader.ts View on Github external
function createZip(filepaths: string[], callback: IZipCallback): void {

    tmp.file({ keep : true, postfix : '.zip' }, (err, zipfilename) => {
        if (err) {
            log('Failure to create zip file', err, filepaths);
            return callback(err);
        }

        const outputStream = fs.createWriteStream(zipfilename);

        const archive = archiver('zip', { zlib : { level : 9 } });

        outputStream.on('close', () => {
            callback(undefined, zipfilename, archive.pointer());
        });

        outputStream.on('warning', (warning) => {
            log('Unexpected warning event from writable filestream', warning);
        });
github Huachao / vscode-restclient / src / controllers / historyController.ts View on Github external
return new Promise((resolve, reject) => {
            tmp.file({ prefix: 'vscode-restclient-', postfix: ".http" }, function _tempFileCreated(err, tmpFilePath, fd) {
                if (err) {
                    reject(err);
                    return;
                }
                let output = `${request.method.toUpperCase()} ${request.url}${EOL}`;
                if (request.headers) {
                    for (const header in request.headers) {
                        if (request.headers.hasOwnProperty(header)) {
                            const value = request.headers[header];
                            output += `${header}: ${value}${EOL}`;
                        }
                    }
                }
                if (request.body) {
                    output += `${EOL}${request.body}`;
                }