Skip to content

don't create folder when it exists #1216

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ exports.main = function main(argv, options, callback) {
try {
stats.writeCount++;
stats.writeTime += measure(() => {
mkdirp(path.join(baseDir, path.dirname(filename)));
const dirPath = path.join(baseDir, path.dirname(filename));
if (!fs.existsSync(dirPath)) mkdirp(dirPath);
if (typeof contents === "string") {
fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: "utf8" } );
} else {
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