Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect absolute output paths #1217

Merged
merged 4 commits into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ under the licensing terms detailed in LICENSE:
* Jeffrey Charles <[email protected]>
* Vladimir Tikhonov <[email protected]>
* Duncan Uszkay <[email protected]>
* Surma <[email protected]>

Portions of this software are derived from third-party works licensed under
the following terms:
Expand Down
9 changes: 6 additions & 3 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,14 @@ exports.main = function main(argv, options, callback) {
try {
stats.writeCount++;
stats.writeTime += measure(() => {
mkdirp(path.join(baseDir, path.dirname(filename)));
const dirPath = path.resolve(baseDir, path.dirname(filename));
filename = path.basename(filename);
const outputFilePath = path.join(dirPath, filename);
if (!fs.existsSync(dirPath)) mkdirp(dirPath);
if (typeof contents === "string") {
fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: "utf8" } );
fs.writeFileSync(outputFilePath, contents, { encoding: "utf8" } );
} else {
fs.writeFileSync(path.join(baseDir, filename), contents);
fs.writeFileSync(outputFilePath, contents);
}
});
return true;
Expand Down
11 changes: 5 additions & 6 deletions cli/util/mkdirp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @fileoverview Recursive mkdir.
* @license
* Copyright 2010 James Halliday ([email protected])
*
*
* This project is free software released under the MIT/X11 license:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -11,7 +11,7 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
Expand All @@ -24,17 +24,16 @@
* THE SOFTWARE.
*/

var path = require("path");
var fs = require("fs");
var _0777 = parseInt("0777", 8);
const path = require("path");
const fs = require("fs");

module.exports = function mkdirp(p, opts, made) {
if (!opts || typeof opts !== "object") {
opts = { mode: opts };
}
var mode = opts.mode;
if (mode === undefined) {
mode = _0777 & (~process.umask());
mode = 0o777 & (~process.umask());
}
if (!made) made = null;
p = path.resolve(p);
Expand Down
2 changes: 1 addition & 1 deletion cli/util/utf8.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var utf8 = exports;
utf8.length = function utf8_length(string) {
var len = 0,
c = 0;
for (var i = 0; i < string.length; ++i) {
for (var i = 0, l = string.length; i < l; ++i) {
c = string.charCodeAt(i);
if (c < 128)
len += 1;
Expand Down