-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e365fe
commit 7714c66
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ | |
"src", | ||
"dist" | ||
], | ||
"browser": { | ||
"fs-extra": false, | ||
"./src/text-encoder.js": "./src/text-encoder.browser.js", | ||
"./src/temp-dir.js": "./src/temp-dir.browser.js" | ||
}, | ||
"repository": "github:ipfs/js-ipfs-utils", | ||
"scripts": { | ||
"test": "aegir test", | ||
|
@@ -34,6 +39,7 @@ | |
"iso-url": "^0.4.7", | ||
"it-glob": "0.0.7", | ||
"merge-options": "^2.0.0", | ||
"nanoid": "^2.1.11", | ||
"node-fetch": "^2.6.0", | ||
"stream-to-it": "^0.2.0" | ||
}, | ||
|
@@ -52,9 +58,5 @@ | |
"Alex Potsides <[email protected]>", | ||
"Alan Shaw <[email protected]>", | ||
"Marcin Rataj <[email protected]>" | ||
], | ||
"browser": { | ||
"fs-extra": false, | ||
"./src/text-encoder.js": "./src/text-encoder.browser.js" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict' | ||
|
||
const nanoid = require('nanoid') | ||
|
||
/** | ||
* Temporary folder | ||
* | ||
* @param {function(string): string} transform - Transform function to add prefixes or sufixes to the unique id | ||
* @returns {string} - Full real path to a temporary folder | ||
*/ | ||
const tempdir = (transform = d => d) => { | ||
return transform(nanoid()) | ||
} | ||
|
||
module.exports = tempdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const os = require('os') | ||
const path = require('path') | ||
const nanoid = require('nanoid') | ||
|
||
/** | ||
* Temporary folder | ||
* | ||
* @param {function(string): string} transform - Transform function to add prefixes or sufixes to the unique id | ||
* @returns {string} - Full real path to a temporary folder | ||
*/ | ||
const tempdir = (transform = d => d) => { | ||
const osTmpDir = fs.realpathSync(os.tmpdir()) | ||
return path.join(osTmpDir, transform(nanoid())) | ||
} | ||
|
||
module.exports = tempdir |