Skip to content

Commit

Permalink
JSDoc config JSON: Fix paths on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Mar 11, 2019
1 parent 207a506 commit 2707f80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
18 changes: 12 additions & 6 deletions lib/processors/jsdoc/jsdocGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,31 @@ const jsdocGenerator = async function({sourcePath, targetPath, tmpPath, options}
async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName, version, variants}) {
// Resolve path to this script to get the path to the JSDoc extensions folder
const jsdocPath = path.normalize(__dirname);
const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.js");
const templatePath = path.join(jsdocPath, "lib", "ui5", "template");
const jsapiFilePath = path.join(targetPath, "libraries", projectName + ".js");
const apiJsonFolderPath = path.join(tmpPath, "dependency-apis");
const apiJsonFilePath =
path.join(targetPath, "test-resources", path.normalize(namespace), "designtime", "api.json");

const config = `{
"plugins": ["${jsdocPath}/lib/ui5/plugin.js"],
"plugins": ["${pluginPath}"],
"opts": {
"recurse": true,
"lenient": true,
"template": "${jsdocPath}/lib/ui5/template",
"template": "${templatePath}",
"ui5": {
"saveSymbols": true
},
"destination": "${tmpPath}"
"destination": "${path.normalize(tmpPath)}"
},
"templates": {
"ui5": {
"variants": ${JSON.stringify(variants)},
"version": "${version}",
"jsapiFile": "${targetPath}/libraries/${projectName}.js",
"apiJsonFolder": "${tmpPath}/dependency-apis",
"apiJsonFile": "${targetPath}/test-resources/${namespace}/designtime/api.json"
"jsapiFile": "${jsapiFilePath}",
"apiJsonFolder": "${apiJsonFolderPath}",
"apiJsonFile": "${apiJsonFilePath}"
}
}
}`;
Expand Down
15 changes: 9 additions & 6 deletions test/lib/processors/jsdoc/jsdocGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ test("generateJsdocConfig", async (t) => {
const jsdocGeneratorPath = path.resolve(__dirname, "..", "..", "..", "..", "lib", "processors",
"jsdoc");

const apiJsonPath =
path.join("/", "some", "target", "path", "test-resources", "some", "namespace", "designtime", "api.json");

t.deepEqual(res, `{
"plugins": ["${jsdocGeneratorPath}/lib/ui5/plugin.js"],
"plugins": ["${path.join(jsdocGeneratorPath, "lib", "ui5", "plugin.js")}"],
"opts": {
"recurse": true,
"lenient": true,
"template": "${jsdocGeneratorPath}/lib/ui5/template",
"template": "${path.join(jsdocGeneratorPath, "lib", "ui5", "template")}",
"ui5": {
"saveSymbols": true
},
"destination": "/some/tmp/path"
"destination": "${path.join("/", "some", "tmp", "path")}"
},
"templates": {
"ui5": {
"variants": ["apijson"],
"version": "1.0.0",
"jsapiFile": "/some/target/path/libraries/some.namespace.js",
"apiJsonFolder": "/some/tmp/path/dependency-apis",
"apiJsonFile": "/some/target/path/test-resources/some/namespace/designtime/api.json"
"jsapiFile": "${path.join("/", "some", "target", "path", "libraries", "some.namespace.js")}",
"apiJsonFolder": "${path.join("/", "some", "tmp", "path", "dependency-apis")}",
"apiJsonFile": "${apiJsonPath}"
}
}
}`, "Correct config generated");
Expand Down

0 comments on commit 2707f80

Please sign in to comment.