@rg-dev/stdlib 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/node-env.cjs +5 -6
- package/lib/node-env.d.cts +1 -1
- package/lib/node-env.d.ts +1 -1
- package/lib/node-env.js +5 -6
- package/package.json +1 -1
package/lib/node-env.cjs
CHANGED
|
@@ -359,15 +359,14 @@ function createTempDir() {
|
|
|
359
359
|
fs.mkdirSync(tempDirPath);
|
|
360
360
|
return tempDirPath;
|
|
361
361
|
}
|
|
362
|
-
function createTempFilePath() {
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
const p = import_path.default.join(tmpDir, `temp_file_${timestamp}`);
|
|
362
|
+
function createTempFilePath(ext) {
|
|
363
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}${ext ? `.${ext}` : ""}`;
|
|
364
|
+
const fullPath = import_path.default.join(import_os.default.tmpdir(), name);
|
|
366
365
|
return {
|
|
367
|
-
getName: () =>
|
|
366
|
+
getName: () => fullPath,
|
|
368
367
|
cleanUp: () => {
|
|
369
368
|
try {
|
|
370
|
-
fs.unlinkSync(
|
|
369
|
+
fs.unlinkSync(fullPath);
|
|
371
370
|
} catch (e) {
|
|
372
371
|
}
|
|
373
372
|
}
|
package/lib/node-env.d.cts
CHANGED
|
@@ -31,7 +31,7 @@ declare function isWindows(): boolean;
|
|
|
31
31
|
declare function chmodPlusX(filePath: string): void;
|
|
32
32
|
declare function checkIfDirExistsOrThrow(path: string): Promise<void>;
|
|
33
33
|
declare function createTempDir(): string;
|
|
34
|
-
declare function createTempFilePath(): {
|
|
34
|
+
declare function createTempFilePath(ext?: string): {
|
|
35
35
|
getName: () => string;
|
|
36
36
|
cleanUp: () => void;
|
|
37
37
|
};
|
package/lib/node-env.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare function isWindows(): boolean;
|
|
|
31
31
|
declare function chmodPlusX(filePath: string): void;
|
|
32
32
|
declare function checkIfDirExistsOrThrow(path: string): Promise<void>;
|
|
33
33
|
declare function createTempDir(): string;
|
|
34
|
-
declare function createTempFilePath(): {
|
|
34
|
+
declare function createTempFilePath(ext?: string): {
|
|
35
35
|
getName: () => string;
|
|
36
36
|
cleanUp: () => void;
|
|
37
37
|
};
|
package/lib/node-env.js
CHANGED
|
@@ -346,15 +346,14 @@ function createTempDir() {
|
|
|
346
346
|
fs.mkdirSync(tempDirPath);
|
|
347
347
|
return tempDirPath;
|
|
348
348
|
}
|
|
349
|
-
function createTempFilePath() {
|
|
350
|
-
const
|
|
351
|
-
const
|
|
352
|
-
const p = path.join(tmpDir, `temp_file_${timestamp}`);
|
|
349
|
+
function createTempFilePath(ext) {
|
|
350
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}${ext ? `.${ext}` : ""}`;
|
|
351
|
+
const fullPath = path.join(os.tmpdir(), name);
|
|
353
352
|
return {
|
|
354
|
-
getName: () =>
|
|
353
|
+
getName: () => fullPath,
|
|
355
354
|
cleanUp: () => {
|
|
356
355
|
try {
|
|
357
|
-
fs.unlinkSync(
|
|
356
|
+
fs.unlinkSync(fullPath);
|
|
358
357
|
} catch (e) {
|
|
359
358
|
}
|
|
360
359
|
}
|