diff --git a/NOTICE b/NOTICE index 3cbcecc156..312b59d128 100644 --- a/NOTICE +++ b/NOTICE @@ -20,6 +20,7 @@ under the licensing terms detailed in LICENSE: * Jeffrey Charles * Vladimir Tikhonov * Duncan Uszkay +* Surma Portions of this software are derived from third-party works licensed under the following terms: diff --git a/cli/asc.js b/cli/asc.js index 38e8eb56fb..8a38d2d3ba 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -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; diff --git a/cli/util/mkdirp.js b/cli/util/mkdirp.js index bc7bffa8bb..59da6513f0 100644 --- a/cli/util/mkdirp.js +++ b/cli/util/mkdirp.js @@ -2,7 +2,7 @@ * @fileoverview Recursive mkdir. * @license * Copyright 2010 James Halliday (mail@substack.net) - * + * * This project is free software released under the MIT/X11 license: * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -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. * @@ -24,9 +24,8 @@ * 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") { @@ -34,7 +33,7 @@ module.exports = function mkdirp(p, opts, made) { } var mode = opts.mode; if (mode === undefined) { - mode = _0777 & (~process.umask()); + mode = 0o777 & (~process.umask()); } if (!made) made = null; p = path.resolve(p); diff --git a/cli/util/utf8.js b/cli/util/utf8.js index 0b37c859b1..076038b10b 100644 --- a/cli/util/utf8.js +++ b/cli/util/utf8.js @@ -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;