How to use the tmpNameSync function from tmp
Find comprehensive JavaScript tmp.tmpNameSync code examples handpicked from public code repositorys.
tmp.tmpNameSync is a synchronous function that generates a unique temporary filename.
GitHub: raszi/node-tmp
197 198 199 200 201 202 203 204 205 206
A synchronous version of the above. ```javascript const tmp = require('tmp'); const name = tmp.tmpNameSync(); console.log('Created temporary filename: ', name); ``` ## Advanced usage
97
711
7
59 60 61 62 63 64 65 66 67 68
// 'src', // '_main.scss', // ); const addonsThemeLoaderVariablesPath = tmp.tmpNameSync({ postfix: '.scss' }); const addonsThemeLoaderMainPath = tmp.tmpNameSync({ postfix: '.scss' }); fs.writeFileSync( addonsThemeLoaderVariablesPath, new Buffer.from(getAddonsLoaderCode('variables', variables)), );
266
251
0
+ 3 other calls in file
How does tmp.tmpNameSync work?
tmp.tmpNameSync
is a function in the tmp
module of Node.js that generates a unique temporary file or directory name synchronously based on a provided prefix, postfix, and directory path.
GitHub: bmeck/node-tmp
126 127 128 129 130 131 132 133 134 135
A synchrounous version of the above. ```javascript var tmp = require('tmp'); var name = tmp.tmpNameSync(); console.log("Created temporary filename: ", name); ``` ## Advanced usage
97
0
2
+ 3 other calls in file
97 98 99 100 101 102 103 104 105 106
Processor.prototype._tmpName = function (extension) { extension = extension || '' if (extension.length) extension = '.' + extension return tmp.tmpNameSync({ postfix: extension }) } Processor.prototype._tmpDir = function () { return tmp.dirSync().name
53
262
18
Ai Example
1 2 3 4 5
const tmp = require("tmp"); const tmpFileName = tmp.tmpNameSync(); console.log(tmpFileName);
This code will generate a unique temporary filename using the default prefix and postfix, and return it as a string.
GitHub: alexivkin/forkrefresh
145 146 147 148 149 150 151 152 153 154
status.start(); const archive = await this.octokit.repos.getArchiveLink({owner:creds.username, repo:reponame, archive_format:'zipball', ref:branch}) status.stop(); // console.log(archivelink) let tmpname = tmp.tmpNameSync(); fs.writeFileSync(tmpname, archive.data); module.exports.tmpdir=tmp.dirSync(); // console.log(tree)
20
31
4
GitHub: cloudant/couchbackup
21 22 23 24 25 26 27 28 29 30
function apiDefaults() { return { parallelism: 5, bufferSize: 500, requestTimeout: 120000, log: tmp.tmpNameSync(), resume: false, mode: 'full' }; }
16
60
63
GitHub: KevinRoebert/rambox-build
496 497 498 499 500 501 502 503 504 505
if ( config.get('user_agent').length > 0 ) tmpWindow.webContents.setUserAgent( config.get('user_agent') ); tmpWindow.webContents.session.once('will-download', (event, downloadItem) => { imageCache[url] = file = { path: tmp.tmpNameSync() + '.' + mime.extension(downloadItem.getMimeType()) ,complete: false }; downloadItem.setSavePath(file.path);
3
4
0
+ 3 other calls in file
6 7 8 9 10 11 12 13 14 15 16 17
module.exports = function (spec) { let that = null; let clips = []; let outputFileName = tmp.tmpNameSync({ prefix: 'video-output-', postfix: '.mp4' });
2
4
0
+ 3 other calls in file
GitHub: Cloud-V/Backend
86 87 88 89 90 91 92 93 94 95
const createMediaFile = async ({ path, buffer }, metadata, cb) => { const fileModel = require("../models/media_file").model; return new Promise(async (resolve, reject) => { let filePath = path; if (buffer) { filePath = tmp.tmpNameSync(); fs.writeFileSync(filePath, buffer); } const fsName = shortid.generate() + "_" + Date.now() + "." + metadata.extension;
0
2
3
GitHub: Jsonize/dockerish
195 196 197 198 199 200 201 202 203 204
"MAINTAINER " + target.dockerfile.maintainer ]; if (options.nocache) dockerfileLines.push("RUN echo " + (new Date()).getTime()); dockerfileLines = dockerfileLines.concat(target.dockerfile.commands.split("\n")); var tempDockerfile = Tmp.tmpNameSync({ template: targetDir + "/Dockerfile-tmp-XXXXXX" }); tempFiles.push(tempDockerfile); FS.writeFileSync(tempDockerfile, dockerfileLines.join("\n"));
0
2
0
+ 5 other calls in file
15 16 17 18 19 20 21 22 23 24 25
} function uploadTextFile(text, dst, sftp){ var tmpFile = tmp.tmpNameSync(); fs.writeFileSync(tmpFile, text, {encoding: 'utf8'}); return new Promise((success, fail) => { sftp.fastPut(tmpFile, dst, err => {
0
0
2
+ 3 other calls in file
21 22 23 24 25 26 27 28 29 30
stderr += data.toString(); } }; tmp.setGracefulCleanup(); const filename = tmp.tmpNameSync({postfix: '.py'}); fs.writeFileSync(filename, util ? utilityFunctions + script : script); try { await exec.exec('python', [filename], options); } catch (error) {
0
0
0
125 126 127 128 129 130 131 132 133 134
var bin = editorOpts.shift(); this.editor = { args: editorOpts, bin: bin }; }; ExternalEditor.prototype.createTemporaryFile = function () { try { this.tempFile = tmp_1.tmpNameSync(this.fileOptions); var opt = { encoding: "utf8" }; if (this.fileOptions.hasOwnProperty("mode")) { opt.mode = this.fileOptions.mode; }
0
0
0
tmp.dirSync is the most popular function in tmp (114 examples)