Skip to content

Commit

Permalink
generateJsdoc: Always create tmp dirs
Browse files Browse the repository at this point in the history
This prevents JSDoc errors in case no resources have written to the
source path.
  • Loading branch information
RandomByte committed Mar 14, 2019
1 parent 7d3e696 commit 088cb4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/tasks/jsdoc/generateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ async function createTmpDirs(projectName) {
const {path: tmpDirPath} = await createTmpDir(projectName);

const sourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
await makeDir(sourcePath, {fs});
const targetPath = path.join(tmpDirPath, "target"); // dir will be created by jsdoc itself
await makeDir(targetPath, {fs});

const tmpPath = path.join(tmpDirPath, "tmp"); // dir needs to be created by us
await makeDir(tmpPath, {fs});
Expand Down
9 changes: 7 additions & 2 deletions test/lib/tasks/jsdoc/generateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ test.serial("createTmpDirs", async (t) => {
targetPath: path.join("/", "some", "path", "target"),
tmpPath: path.join("/", "some", "path", "tmp")
}, "Correct temporary directories returned");
t.deepEqual(makeDirStub.callCount, 1, "One directory got created");
t.deepEqual(makeDirStub.getCall(0).args[0], path.join("/", "some", "path", "tmp"), "Correct dir path got created");
t.deepEqual(makeDirStub.callCount, 3, "One directory got created");
t.deepEqual(makeDirStub.getCall(0).args[0], path.join("/", "some", "path", "src"),
"Correct srcdir path got created");
t.deepEqual(makeDirStub.getCall(1).args[0], path.join("/", "some", "path", "target"),
"Correct target dir path got created");
t.deepEqual(makeDirStub.getCall(2).args[0], path.join("/", "some", "path", "tmp"),
"Correct tmp dir path got created");

mock.stop("make-dir");
});
Expand Down

0 comments on commit 088cb4b

Please sign in to comment.