From 2707f8064cbea31434ff6a7ec6b983d9a2cb56db Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Mon, 11 Mar 2019 13:43:06 +0100 Subject: [PATCH] JSDoc config JSON: Fix paths on Windows --- lib/processors/jsdoc/jsdocGenerator.js | 18 ++++++++++++------ test/lib/processors/jsdoc/jsdocGenerator.js | 15 +++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/processors/jsdoc/jsdocGenerator.js b/lib/processors/jsdoc/jsdocGenerator.js index 6821421d8..d89bb29f8 100644 --- a/lib/processors/jsdoc/jsdocGenerator.js +++ b/lib/processors/jsdoc/jsdocGenerator.js @@ -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}" } } }`; diff --git a/test/lib/processors/jsdoc/jsdocGenerator.js b/test/lib/processors/jsdoc/jsdocGenerator.js index 5a344c47c..1fb7b3479 100644 --- a/test/lib/processors/jsdoc/jsdocGenerator.js +++ b/test/lib/processors/jsdoc/jsdocGenerator.js @@ -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");