We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1dbd3f3 commit f6d9559Copy full SHA for f6d9559
lib/io.js
@@ -53,6 +53,15 @@ export function readScript(filepath)
53
54
export function saveScript(ast, filepath)
55
{
56
+ ensureParentDirExists(filepath);
57
+
58
+ let stat = fs.statSync(filepath, {throwIfNoEntry: false});
59
+ if (stat && stat.isDirectory())
60
+ {
61
+ saveScript(ast, path.join(filepath, "index.js"));
62
+ return;
63
+ }
64
65
let code = astToCode(ast, {
66
format: {
67
indent: {
@@ -64,6 +73,5 @@ export function saveScript(ast, filepath)
73
comment: true
74
});
75
- ensureParentDirExists(filepath);
68
76
fs.writeFileSync(filepath, code, {encoding: "utf-8"});
69
77
}
0 commit comments