Browse Source

fix: remove codeFns every time when compiling

master
smallstonesk 4 years ago
parent
commit
c9e6738ced
  1. 6
      packages/cli/src/cmd/dev/extractCodes.js

6
packages/cli/src/cmd/dev/extractCodes.js

@ -15,7 +15,7 @@ const writeEntryFile = async (basePath, fileIds) => {
`export default nodeFns;`
].join('\n');
const entryFilePath = path.join(basePath, 'index.js');
await fs.writeFile(entryFilePath, fileContent, {encoding: 'utf8', flag:'w'});
await fs.outputFile(entryFilePath, fileContent, {encoding: 'utf8', flag:'w'});
};
const writeNodeCodes = async (basePath, dsl) => {
@ -25,14 +25,14 @@ const writeNodeCodes = async (basePath, dsl) => {
for(const {id, data: {code}} of nodes) {
fileIds.push(id);
const filePath = path.join(basePath, id + '.js');
await fs.writeFile(filePath, code, {encoding: 'utf8', flag:'w'});
await fs.outputFile(filePath, code, {encoding: 'utf8', flag:'w'});
}
return fileIds;
};
const setup = async (dsl, logicBasePath) => {
const nodeCodesPath = path.join(logicBasePath, 'nodeFns');
await fs.ensureDir(nodeCodesPath);
await fs.remove(nodeCodesPath);
const fileIds = await writeNodeCodes(nodeCodesPath, dsl);
await writeEntryFile(nodeCodesPath, fileIds);
};

Loading…
Cancel
Save