Skip to content

Commit

Permalink
Fix tmp dir cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Feb 28, 2019
1 parent 8028a0f commit f7b68fe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/tasks/generateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = async function({workspace, options}) {
allResources = await workspace.byGlob(options.pattern);
}

const {path: tmpDirPath, cleanupCallback} = await createTmpWorkDir(options.projectName);
const {path: tmpDirPath} = await createTmpWorkDir(options.projectName);
const tmpSourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
const tmpTargetPath = path.join(tmpDirPath, "target"); // dir will be created by jsdoc itself
const tmpTmpPath = path.join(tmpDirPath, "tmp"); // dir needs to be created by us
Expand All @@ -58,25 +58,25 @@ module.exports = async function({workspace, options}) {
});

console.log(createdResources);
await Promise.all(createdResources.map((resource) => {
return workspace.write(resource);
// TODO: cleanupCallback
await Promise.all(createdResources.map(async (resource) => {
await workspace.write(resource);
}));
};

function createTmpWorkDir(projectName) {
return new Promise((resolve, reject) => {
tmp.dir({
prefix: `ui5-tooling-tmp-jsdoc-${projectName}-`
}, (err, path, cleanupCallback) => {
prefix: `ui5-tooling-tmp-jsdoc-${projectName}-`,
// keep: true,
unsafeCleanup: true
}, (err, path) => {
if (err) {
reject(err);
return;
}

resolve({
path,
cleanupCallback
path
});
});
});
Expand Down

0 comments on commit f7b68fe

Please sign in to comment.