diff --git a/lib/task.js b/lib/task.js index 82f6437..dc87ff3 100644 --- a/lib/task.js +++ b/lib/task.js @@ -3,8 +3,8 @@ const path = require("path"); const fs = require("fs").promises; function compareVersions(v1, v2) { - const parts1 = v1.split("_").map(Number); - const parts2 = v2.split("_").map(Number); + const parts1 = v1.split(".").map(Number); + const parts2 = v2.split(".").map(Number); for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) { const part1 = parts1[i] || 0; @@ -53,21 +53,23 @@ module.exports = async function ({ log, workspace, taskUtil, options }) { // Check if ui5-cc-spreadsheetimporter is present in dependencies const packageJsonPath = path.join(cwd, "package.json"); const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8")); - const hasSpreadsheetImporter = packageJson.dependencies && packageJson.dependencies["ui5-cc-spreadsheetimporter"]; - // replace all "." with "_" from hasSpreadsheetImporter - const spreadsheetimporterversion = hasSpreadsheetImporter.replace(/\./g, "_"); - + const hasSpreadsheetImporter = + packageJson.dependencies?.["ui5-cc-spreadsheetimporter"] || + packageJson.devDependencies?.["ui5-cc-spreadsheetimporter"]; if (!hasSpreadsheetImporter) { isDebug && log.info("ui5-cc-spreadsheetimporter not found in dependencies. Skipping manifest change."); return; } + const spreadsheetImporterVersionPoint = hasSpreadsheetImporter; + // replace all "." with "_" from hasSpreadsheetImporter + const spreadsheetimporterversion = spreadsheetImporterVersionPoint.replace(/\./g, "_"); // Find the manifest.json for ui5-cc-spreadsheetimporter const spreadsheetImportermanifestContent = await fs.readFile(nodeModuleSpreadsheetImporterManifestPath, "utf8"); - // if spreadsheetimporterversion less than 0_34_0, then use customControl and spreadsheetImporter - const useCustomControl = compareVersions(spreadsheetimporterversion, "0_34_0") < 0; - const pathSegment = useCustomControl ? "customControl/spreadsheetImporter" : "customControl/spreadsheetImporter"; + // if spreadsheetImporterVersionPoint less than "0.34.0", then use customControl and spreadsheetImporter + const useCustomControl = compareVersions(spreadsheetImporterVersionPoint, "0.34.0") < 0; + const pathSegment = useCustomControl ? "customControl/spreadsheetImporter" : "customcontrol/spreadsheetimporter"; const spreadsheetImporterManifestPath = `/resources/${taskUtil .getProject()