Skip to content

Commit bf379c3

Browse files
committed
Remove output file check
1 parent 36f79aa commit bf379c3

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
out
2+
out
3+
*.tgz

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Install by running `npm i -g source-map-unpacker`
99
Usage: unmap [options]
1010
1111
Options:
12-
-p, --path <p> input map file
13-
-f, --filter <f> string to filter out files
14-
-o, --output <o> output folder
15-
-h, --help output usage information
12+
-p, --path <p> input source map file
13+
-f, --filter <f> filter out file names
14+
-o, --output <o> output folder (default: "./")
15+
-h, --help display help for command
1616
```

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"name": "source-map-unpacker",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "",
55
"main": "unmap.js",
66
"bin": {
77
"unpack": "unmap.js"
88
},
9+
"engines": {
10+
"node": ">10"
11+
},
912
"scripts": {
1013
"test": "node . -p test/gistfile1.js.map -o out"
1114
},

unmap.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@ const opts = program
1313
.parse(process.argv)
1414
.opts();
1515

16-
// stat output folder
17-
fs.stat(opts.output)
18-
.then(async () => {
19-
// if output folder exists continue
20-
return fs.readFile(opts.path);
21-
})
16+
fs.readFile(opts.path)
2217
.catch(async (e) => {
23-
// if output folder does not exist, make it.
24-
await fs.mkdir(opts.output);
25-
return fs.readFile(opts.path);
18+
console.log("Input file does not exists");
19+
process.exit(1);
2620
})
2721
.then((js) => {
2822
js = JSON.parse(js.toString());
2923

3024
const files = js.sources
3125
.filter((path) => (opts.filter ? path.includes(opts.filter) : true))
32-
.map((path, idx) =>
33-
fs.outputFile(resolve(opts.output, path), js.sourcesContent[idx])
34-
);
26+
.map((path, idx) => {
27+
const outpath = resolve(opts.output, path);
28+
return fs.outputFile(outpath, js.sourcesContent[idx]);
29+
});
3530
return Promise.all(files);
3631
})
3732
.then(() => console.log(`${opts.path} unpacked`));

0 commit comments

Comments
 (0)