tsoa
This commit is contained in:
9
node_modules/@hapi/file/lib/index.d.ts
generated
vendored
Executable file
9
node_modules/@hapi/file/lib/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
Generate a random file name within a given path and optional extension.
|
||||
|
||||
@param path - The file path within to generate a temporary file.
|
||||
@param extension - File extension.
|
||||
|
||||
@return The generarted filename.
|
||||
*/
|
||||
export function uniqueFilename(path: string, extension?: string): string;
|
||||
22
node_modules/@hapi/file/lib/index.js
generated
vendored
Executable file
22
node_modules/@hapi/file/lib/index.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const Crypto = require('crypto');
|
||||
const Path = require('path');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.uniqueFilename = function (path, extension) {
|
||||
|
||||
if (extension) {
|
||||
extension = extension[0] !== '.' ? '.' + extension : extension;
|
||||
}
|
||||
else {
|
||||
extension = '';
|
||||
}
|
||||
|
||||
path = Path.resolve(path);
|
||||
const name = [Date.now(), process.pid, Crypto.randomBytes(8).toString('hex')].join('-') + extension;
|
||||
return Path.join(path, name);
|
||||
};
|
||||
Reference in New Issue
Block a user