Skip to content

Commit 02892c7

Browse files
surmaMaxGraey
andauthored
Respect absolute output paths (#1217)
Co-authored-by: MaxGraey <[email protected]>
1 parent 2914b87 commit 02892c7

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

NOTICE

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ under the licensing terms detailed in LICENSE:
2020
* Jeffrey Charles <[email protected]>
2121
* Vladimir Tikhonov <[email protected]>
2222
* Duncan Uszkay <[email protected]>
23+
2324

2425
Portions of this software are derived from third-party works licensed under
2526
the following terms:

cli/asc.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,14 @@ exports.main = function main(argv, options, callback) {
10411041
try {
10421042
stats.writeCount++;
10431043
stats.writeTime += measure(() => {
1044-
mkdirp(path.join(baseDir, path.dirname(filename)));
1044+
const dirPath = path.resolve(baseDir, path.dirname(filename));
1045+
filename = path.basename(filename);
1046+
const outputFilePath = path.join(dirPath, filename);
1047+
if (!fs.existsSync(dirPath)) mkdirp(dirPath);
10451048
if (typeof contents === "string") {
1046-
fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: "utf8" } );
1049+
fs.writeFileSync(outputFilePath, contents, { encoding: "utf8" } );
10471050
} else {
1048-
fs.writeFileSync(path.join(baseDir, filename), contents);
1051+
fs.writeFileSync(outputFilePath, contents);
10491052
}
10501053
});
10511054
return true;

cli/util/mkdirp.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Recursive mkdir.
33
* @license
44
* Copyright 2010 James Halliday ([email protected])
5-
*
5+
*
66
* This project is free software released under the MIT/X11 license:
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -11,7 +11,7 @@
1111
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1212
* copies of the Software, and to permit persons to whom the Software is
1313
* furnished to do so, subject to the following conditions:
14-
*
14+
*
1515
* The above copyright notice and this permission notice shall be included in
1616
* all copies or substantial portions of the Software.
1717
*
@@ -24,17 +24,16 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
var path = require("path");
28-
var fs = require("fs");
29-
var _0777 = parseInt("0777", 8);
27+
const path = require("path");
28+
const fs = require("fs");
3029

3130
module.exports = function mkdirp(p, opts, made) {
3231
if (!opts || typeof opts !== "object") {
3332
opts = { mode: opts };
3433
}
3534
var mode = opts.mode;
3635
if (mode === undefined) {
37-
mode = _0777 & (~process.umask());
36+
mode = 0o777 & (~process.umask());
3837
}
3938
if (!made) made = null;
4039
p = path.resolve(p);

cli/util/utf8.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var utf8 = exports;
2020
utf8.length = function utf8_length(string) {
2121
var len = 0,
2222
c = 0;
23-
for (var i = 0; i < string.length; ++i) {
23+
for (var i = 0, l = string.length; i < l; ++i) {
2424
c = string.charCodeAt(i);
2525
if (c < 128)
2626
len += 1;

0 commit comments

Comments
 (0)