improve subdirectory handling when writing fileTrees
This commit is contained in:
parent
d29dcc5a1c
commit
65dda3bcf1
7
dist/smartfile.memory.js
vendored
7
dist/smartfile.memory.js
vendored
@ -42,7 +42,9 @@ exports.toFs = (fileContentArg, filePathArg, optionsArg = {}) => __awaiter(this,
|
|||||||
let fileContentArg2 = fileContentArg;
|
let fileContentArg2 = fileContentArg;
|
||||||
fileString = fileContentArg.contentBuffer.toString();
|
fileString = fileContentArg.contentBuffer.toString();
|
||||||
// handle options
|
// handle options
|
||||||
optionsArg.respectRelative ? filePath = plugins.path.join(filePath, fileContentArg.path) : null;
|
if (optionsArg.respectRelative) {
|
||||||
|
filePath = plugins.path.join(filePath, fileContentArg.path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (typeof fileContentArg === 'string') {
|
else if (typeof fileContentArg === 'string') {
|
||||||
fileString = fileContentArg;
|
fileString = fileContentArg;
|
||||||
@ -50,6 +52,7 @@ exports.toFs = (fileContentArg, filePathArg, optionsArg = {}) => __awaiter(this,
|
|||||||
else {
|
else {
|
||||||
throw new Error('fileContent is neither string nor Smartfile');
|
throw new Error('fileContent is neither string nor Smartfile');
|
||||||
}
|
}
|
||||||
|
yield smartfileFs.ensureDir(plugins.path.parse(filePath).dir);
|
||||||
plugins.fsExtra.writeFile(filePath, fileString, 'utf8', done.resolve);
|
plugins.fsExtra.writeFile(filePath, fileString, 'utf8', done.resolve);
|
||||||
return yield done.promise;
|
return yield done.promise;
|
||||||
});
|
});
|
||||||
@ -82,4 +85,4 @@ exports.smartfileArrayToFs = (smartfileArrayArg, dirArg) => __awaiter(this, void
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRmaWxlLm1lbW9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZmlsZS5tZW1vcnkudHMiXSwibmFtZXMiO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E7QUFDN0QsQ0FBQyxDQUFBO0FBRVUsUUFBQSxrQkFBa0IsR0FBRyxDQUFPLGlCQUE4QixFQUFFLE1BQWM7SUFDbkYsTUFBTSxXQUFXLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ25DLEdBQUcsQ0FBQyxDQUFDLElBQUksU0FBUyxJQUFJLGlCQUFpQixDQUFDLENBQUMsQ0FBQztRQUN4QyxNQUFNLFlBQUksQ0FBQyxTQUFTLEVBQUUsTUFBTSxFQUFFO1lBQzVCLGVBQWUsRUFBRSxJQUFJO1NBQ3RCLENBQUMsQ0FBQTtJQUNKLENBQUM7QUFDSCxDQUFDLENBQUEsQ0FBQSJ9
|
@ -43,14 +43,16 @@ export let toFs = async (fileContentArg: string | Smartfile, filePathArg, option
|
|||||||
if (fileContentArg instanceof Smartfile) {
|
if (fileContentArg instanceof Smartfile) {
|
||||||
let fileContentArg2: any = fileContentArg
|
let fileContentArg2: any = fileContentArg
|
||||||
fileString = fileContentArg.contentBuffer.toString()
|
fileString = fileContentArg.contentBuffer.toString()
|
||||||
|
|
||||||
// handle options
|
// handle options
|
||||||
optionsArg.respectRelative ? filePath = plugins.path.join(filePath, fileContentArg.path) : null
|
if (optionsArg.respectRelative) {
|
||||||
|
filePath = plugins.path.join(filePath, fileContentArg.path)
|
||||||
|
}
|
||||||
} else if (typeof fileContentArg === 'string') {
|
} else if (typeof fileContentArg === 'string') {
|
||||||
fileString = fileContentArg
|
fileString = fileContentArg
|
||||||
} else {
|
} else {
|
||||||
throw new Error('fileContent is neither string nor Smartfile')
|
throw new Error('fileContent is neither string nor Smartfile')
|
||||||
}
|
}
|
||||||
|
await smartfileFs.ensureDir(plugins.path.parse(filePath).dir)
|
||||||
plugins.fsExtra.writeFile(filePath, fileString, 'utf8', done.resolve)
|
plugins.fsExtra.writeFile(filePath, fileString, 'utf8', done.resolve)
|
||||||
return await done.promise
|
return await done.promise
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user