UNPKG

@sap-ux/project-access

Version:

Library to access SAP Fiori tools projects

36 lines 1.19 kB
import { join } from 'node:path'; import { FileName } from '../constants.js'; import { readJSON, updatePackageJSON } from '../file/index.js'; import semVer from 'semver'; /** * Updates the package.json with a new script. * * @param basePath - the base path * @param scriptName - the script name * @param script - the script content * @param fs - optional memfs editor instance */ export async function updatePackageScript(basePath, scriptName, script, fs) { const filePath = join(basePath, FileName.Package); const packageJson = await readJSON(filePath, fs); if (!packageJson.scripts) { packageJson.scripts = {}; } packageJson.scripts[scriptName] = script; await updatePackageJSON(filePath, packageJson, fs); } /** * Check if dev dependencies contains @ui5/cli version greater than 2. * * @param devDependencies dev dependencies from package.json * @returns boolean */ export function hasUI5CliV3(devDependencies) { let isV3 = false; const ui5CliSemver = semVer.coerce(devDependencies['@ui5/cli']); if (ui5CliSemver && semVer.gte(ui5CliSemver, '3.0.0')) { isV3 = true; } return isV3; } //# sourceMappingURL=script.js.map