formacao
This commit is contained in:
+5
-6
@@ -65,7 +65,7 @@ export const mkdir = (dir, opt, cb) => {
|
||||
mkdir_(cwd, parts, mode, unlink, cwd, undefined, done);
|
||||
};
|
||||
const mkdir_ = (base, parts, mode, unlink, cwd, created, cb) => {
|
||||
if (!parts.length) {
|
||||
if (parts.length === 0) {
|
||||
return cb(null, created);
|
||||
}
|
||||
const p = parts.shift();
|
||||
@@ -76,8 +76,7 @@ const onmkdir = (part, parts, mode, unlink, cwd, created, cb) => (er) => {
|
||||
if (er) {
|
||||
fs.lstat(part, (statEr, st) => {
|
||||
if (statEr) {
|
||||
statEr.path =
|
||||
statEr.path && normalizeWindowsPath(statEr.path);
|
||||
statEr.path = statEr.path && normalizeWindowsPath(statEr.path);
|
||||
cb(statEr);
|
||||
}
|
||||
else if (st.isDirectory()) {
|
||||
@@ -106,7 +105,7 @@ const onmkdir = (part, parts, mode, unlink, cwd, created, cb) => (er) => {
|
||||
};
|
||||
const checkCwdSync = (dir) => {
|
||||
let ok = false;
|
||||
let code = undefined;
|
||||
let code;
|
||||
try {
|
||||
ok = fs.statSync(dir).isDirectory();
|
||||
}
|
||||
@@ -152,14 +151,14 @@ export const mkdirSync = (dir, opt) => {
|
||||
}
|
||||
const sub = normalizeWindowsPath(path.relative(cwd, dir));
|
||||
const parts = sub.split('/');
|
||||
let created = undefined;
|
||||
let created;
|
||||
for (let p = parts.shift(), part = cwd; p && (part += '/' + p); p = parts.shift()) {
|
||||
part = normalizeWindowsPath(path.resolve(part));
|
||||
try {
|
||||
fs.mkdirSync(part, mode);
|
||||
created = created || part;
|
||||
}
|
||||
catch (er) {
|
||||
catch {
|
||||
const st = fs.lstatSync(part);
|
||||
if (st.isDirectory()) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user