@rg-dev/stdlib 1.0.35 → 1.0.37
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 +11 -3
- package/lib/node-env.d.cts +4 -1
- package/lib/node-env.d.ts +4 -1
- package/lib/node-env.js +11 -3
- package/package.json +1 -1
package/lib/node-env.cjs
CHANGED
|
@@ -360,9 +360,17 @@ function createTempDir() {
|
|
|
360
360
|
return tempDirPath;
|
|
361
361
|
}
|
|
362
362
|
function createTempFilePath() {
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
return
|
|
363
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
364
|
+
const fullPath = import_path.default.join(import_os.default.tmpdir(), name);
|
|
365
|
+
return {
|
|
366
|
+
getName: () => fullPath,
|
|
367
|
+
cleanUp: () => {
|
|
368
|
+
try {
|
|
369
|
+
fs.unlinkSync(fullPath);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
366
374
|
}
|
|
367
375
|
async function throwIfDirNotEmpty(dirPath) {
|
|
368
376
|
if (!await fs.pathExists(dirPath)) {
|
package/lib/node-env.d.cts
CHANGED
|
@@ -31,7 +31,10 @@ 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(): {
|
|
35
|
+
getName: () => string;
|
|
36
|
+
cleanUp: () => void;
|
|
37
|
+
};
|
|
35
38
|
declare function throwIfDirNotEmpty(dirPath: string): Promise<void>;
|
|
36
39
|
declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
|
|
37
40
|
declare function checkIfFileExistsOrThrow(thePath: string): Promise<void>;
|
package/lib/node-env.d.ts
CHANGED
|
@@ -31,7 +31,10 @@ 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(): {
|
|
35
|
+
getName: () => string;
|
|
36
|
+
cleanUp: () => void;
|
|
37
|
+
};
|
|
35
38
|
declare function throwIfDirNotEmpty(dirPath: string): Promise<void>;
|
|
36
39
|
declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
|
|
37
40
|
declare function checkIfFileExistsOrThrow(thePath: string): Promise<void>;
|
package/lib/node-env.js
CHANGED
|
@@ -347,9 +347,17 @@ function createTempDir() {
|
|
|
347
347
|
return tempDirPath;
|
|
348
348
|
}
|
|
349
349
|
function createTempFilePath() {
|
|
350
|
-
const
|
|
351
|
-
const
|
|
352
|
-
return
|
|
350
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
351
|
+
const fullPath = path.join(os.tmpdir(), name);
|
|
352
|
+
return {
|
|
353
|
+
getName: () => fullPath,
|
|
354
|
+
cleanUp: () => {
|
|
355
|
+
try {
|
|
356
|
+
fs.unlinkSync(fullPath);
|
|
357
|
+
} catch (e) {
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
353
361
|
}
|
|
354
362
|
async function throwIfDirNotEmpty(dirPath) {
|
|
355
363
|
if (!await fs.pathExists(dirPath)) {
|