Skip to content

Commit

Permalink
#217: fix uninstall in a build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Dec 10, 2024
1 parent d2336ec commit a1e602d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,37 @@
"console": "internalConsole",
"sourceMaps": false
},
{
"type": "node",
"request": "launch",
"name": "xpm uninstall @xpack-dev-tools/clang",
"program": "${workspaceRoot}/bin/xpm.js",
"stopOnEntry": true,
"args": [
"uninstall",
"@xpack-dev-tools/clang",
"--config",
"native-cmake-clang-release",
"-C",
"/Users/ilg/MyProjects/micro-os-plus.github/xPacks/micro-test-plus-xpack.git/tests",
"-dd"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"skipFiles": [
"async_hooks.js",
"inspector_async_hook.js"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false
},
{
"type": "node",
"request": "launch",
Expand Down
20 changes: 15 additions & 5 deletions lib/xpm/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export class Uninstall extends CliCommand {
const dotBin = context.globalConfig.dotBin

let xPackFolderPath
let xPacksBasePath = config.cwd

if (config.configurationName) {
// Throws if the configuration is not found.
Expand All @@ -311,6 +312,11 @@ export class Uninstall extends CliCommand {
configurationName: config.configurationName
})

xPacksBasePath = path.join(
config.cwd,
buildFolderRelativePath
)

if (this.policies.nonHierarchicalLocalXpacksFolder) {
xPackFolderPath = path.join(
config.cwd,
Expand Down Expand Up @@ -361,6 +367,7 @@ export class Uninstall extends CliCommand {
if (!config.isDryRun) {
// Remove the corresponding bin links.
await this.removeDotBinLinks({
xPacksBasePath,
dotBinRelativePath: path.join(
context.globalConfig.localXpacksFolderName, dotBin),
packagePath: xPackFolderPath
Expand All @@ -385,6 +392,7 @@ export class Uninstall extends CliCommand {
if (!config.isDryRun) {
// Remove the corresponding bin links.
await this.removeDotBinLinks({
xPacksBasePath,
dotBinRelativePath: path.join(
context.globalConfig.localXpacksFolderName, dotBin),
packagePath: xPackFolderPath
Expand Down Expand Up @@ -439,6 +447,7 @@ export class Uninstall extends CliCommand {
if (!config.isDryRun) {
// Remove the corresponding bin links.
await this.removeDotBinLinks({
xPacksBasePath,
dotBinRelativePath: path.join(
context.globalConfig.localNpmFolderName, dotBin),
packagePath: nodeFolderPath
Expand Down Expand Up @@ -600,12 +609,13 @@ export class Uninstall extends CliCommand {
* Iterate the entries in the package `executables` object and remove all
* corresponding links from the `.bin` folder.
*/
async removeDotBinLinks ({ dotBinRelativePath, packagePath }) {
async removeDotBinLinks ({
xPacksBasePath,
dotBinRelativePath,
packagePath
}) {
const log = this.log

const context = this.context
const config = context.config

const json = await this.xpack.isFolderPackage(packagePath)
if (!json) {
return // Not a package (unlikely, but for just in case)
Expand All @@ -622,7 +632,7 @@ export class Uninstall extends CliCommand {
}

const executablesAbsolutePath =
path.join(config.cwd, dotBinRelativePath)
path.join(xPacksBasePath, dotBinRelativePath)
for (const key of Object.keys(packageExecutablesPath)) {
const linkPath = path.join(executablesAbsolutePath, key)

Expand Down

0 comments on commit a1e602d

Please sign in to comment.