Skip to content

Commit d1734db

Browse files
committed
fix: Bug fixes for git and npm global install
1 parent 0778e33 commit d1734db

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "1.0.0-beta1",
3+
"version": "1.0.0",
44
"description": "Default plugin for Codify - provides 50+ declarative resources for managing development tools and system configuration across macOS and Linux",
55
"main": "dist/index.js",
66
"scripts": {

src/resources/git/repository/git-repository-schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"additionalProperties": false,
3434
"oneOf": [
3535
{ "required": ["repository", "directory"] },
36+
{ "required": ["repository", "parentDirectory"] },
3637
{ "required": ["repositories", "parentDirectory"] }
3738
]
3839
}

src/resources/javascript/npm/global-install.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ export class NpmGlobalInstallParameter extends StatefulParameter<NpmConfig, Arra
6363
async modify(newValue: (NpmPackage | string)[], previousValue: (NpmPackage | string)[], plan: Plan<NpmConfig>): Promise<void> {
6464
const toInstall = newValue.filter((n) => !previousValue.some((p) => this.isSamePackage(n, p)));
6565
const toUninstall = previousValue.filter((p) => !newValue.some((n) => this.isSamePackage(n, p)));
66-
67-
await this.uninstall(toUninstall);
66+
67+
if (plan.isStateful && toUninstall.length > 0) {
68+
await this.uninstall(toUninstall);
69+
}
6870
await this.install(toInstall);
6971
}
7072

@@ -86,6 +88,10 @@ export class NpmGlobalInstallParameter extends StatefulParameter<NpmConfig, Arra
8688
return p.name;
8789
})
8890

91+
if (installStatements.length === 0) {
92+
return;
93+
}
94+
8995
await $.spawn(`npm install --global ${installStatements.join(' ')}`, { interactive: true });
9096
}
9197

@@ -99,6 +105,10 @@ export class NpmGlobalInstallParameter extends StatefulParameter<NpmConfig, Arra
99105
return p.name;
100106
})
101107

108+
if (uninstallStatements.length === 0) {
109+
return;
110+
}
111+
102112
await $.spawn(`npm uninstall --global ${uninstallStatements.join(' ')}`, { interactive: true });
103113
}
104114

0 commit comments

Comments
 (0)