@rg-dev/stdlib 1.0.35 → 1.0.36

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 CHANGED
@@ -362,7 +362,16 @@ function createTempDir() {
362
362
  function createTempFilePath() {
363
363
  const tmpDir = import_os.default.tmpdir();
364
364
  const timestamp = Date.now();
365
- return import_path.default.join(tmpDir, `temp_file_${timestamp}`);
365
+ const p = import_path.default.join(tmpDir, `temp_file_${timestamp}`);
366
+ return {
367
+ getName: () => p,
368
+ cleanUp: () => {
369
+ try {
370
+ fs.unlinkSync(p);
371
+ } catch (e) {
372
+ }
373
+ }
374
+ };
366
375
  }
367
376
  async function throwIfDirNotEmpty(dirPath) {
368
377
  if (!await fs.pathExists(dirPath)) {
@@ -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(): string;
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(): string;
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
@@ -349,7 +349,16 @@ function createTempDir() {
349
349
  function createTempFilePath() {
350
350
  const tmpDir = os.tmpdir();
351
351
  const timestamp = Date.now();
352
- return path.join(tmpDir, `temp_file_${timestamp}`);
352
+ const p = path.join(tmpDir, `temp_file_${timestamp}`);
353
+ return {
354
+ getName: () => p,
355
+ cleanUp: () => {
356
+ try {
357
+ fs.unlinkSync(p);
358
+ } catch (e) {
359
+ }
360
+ }
361
+ };
353
362
  }
354
363
  async function throwIfDirNotEmpty(dirPath) {
355
364
  if (!await fs.pathExists(dirPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",