@rg-dev/stdlib 1.0.37 → 1.0.39
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 +6 -3
- package/lib/node-env.d.cts +1 -1
- package/lib/node-env.d.ts +1 -1
- package/lib/node-env.js +6 -3
- package/package.json +1 -1
package/lib/node-env.cjs
CHANGED
|
@@ -353,14 +353,17 @@ async function checkIfDirExistsOrThrow(path2) {
|
|
|
353
353
|
function createTempDir() {
|
|
354
354
|
const tmpDir = import_os.default.tmpdir();
|
|
355
355
|
const timestamp = Date.now();
|
|
356
|
-
const tempDirName = `temp_dir_${timestamp}`;
|
|
356
|
+
const tempDirName = `temp_dir_${timestamp}_${Math.random().toString(36).slice(2)}`;
|
|
357
357
|
const tempDirPath = import_path.default.join(tmpDir, tempDirName);
|
|
358
358
|
console.log("tempDir", tempDirPath);
|
|
359
359
|
fs.mkdirSync(tempDirPath);
|
|
360
360
|
return tempDirPath;
|
|
361
361
|
}
|
|
362
|
-
function createTempFilePath() {
|
|
363
|
-
|
|
362
|
+
function createTempFilePath(ext) {
|
|
363
|
+
if (ext.startsWith(".")) {
|
|
364
|
+
ext = ext.slice(1);
|
|
365
|
+
}
|
|
366
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}${ext ? `.${ext}` : ""}`;
|
|
364
367
|
const fullPath = import_path.default.join(import_os.default.tmpdir(), name);
|
|
365
368
|
return {
|
|
366
369
|
getName: () => fullPath,
|
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
|
@@ -340,14 +340,17 @@ async function checkIfDirExistsOrThrow(path2) {
|
|
|
340
340
|
function createTempDir() {
|
|
341
341
|
const tmpDir = os.tmpdir();
|
|
342
342
|
const timestamp = Date.now();
|
|
343
|
-
const tempDirName = `temp_dir_${timestamp}`;
|
|
343
|
+
const tempDirName = `temp_dir_${timestamp}_${Math.random().toString(36).slice(2)}`;
|
|
344
344
|
const tempDirPath = path.join(tmpDir, tempDirName);
|
|
345
345
|
console.log("tempDir", tempDirPath);
|
|
346
346
|
fs.mkdirSync(tempDirPath);
|
|
347
347
|
return tempDirPath;
|
|
348
348
|
}
|
|
349
|
-
function createTempFilePath() {
|
|
350
|
-
|
|
349
|
+
function createTempFilePath(ext) {
|
|
350
|
+
if (ext.startsWith(".")) {
|
|
351
|
+
ext = ext.slice(1);
|
|
352
|
+
}
|
|
353
|
+
const name = `temp_file_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2)}${ext ? `.${ext}` : ""}`;
|
|
351
354
|
const fullPath = path.join(os.tmpdir(), name);
|
|
352
355
|
return {
|
|
353
356
|
getName: () => fullPath,
|