@wpmoo/toolkit 0.9.16 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/module-actions.js +10 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -856,7 +856,7 @@ async function removeModuleOptionsFromPrompts(showIntro = true, cancelAction = '
|
|
|
856
856
|
message: menuPromptMessage('Delete module files too?', cancelAction),
|
|
857
857
|
active: 'Y',
|
|
858
858
|
inactive: 'n',
|
|
859
|
-
initialValue:
|
|
859
|
+
initialValue: cancelAction === 'back',
|
|
860
860
|
});
|
|
861
861
|
handleCancel(deleteFiles, cancelAction);
|
|
862
862
|
return {
|
|
@@ -1234,7 +1234,7 @@ async function runSelectedModuleAction(action, module, cwd) {
|
|
|
1234
1234
|
message: menuPromptMessage('Delete module files too?', 'back'),
|
|
1235
1235
|
active: 'Y',
|
|
1236
1236
|
inactive: 'n',
|
|
1237
|
-
initialValue:
|
|
1237
|
+
initialValue: true,
|
|
1238
1238
|
});
|
|
1239
1239
|
handleCancel(deleteFiles, 'back');
|
|
1240
1240
|
const removeCommand = cockpitCommands.find((entry) => entry.id === 'remove-module');
|
package/dist/module-actions.js
CHANGED
|
@@ -355,7 +355,7 @@ async function assertModuleCleanBeforeDelete(target, sourceType, repoPath, modul
|
|
|
355
355
|
const repoRoot = sourceRepoPath(target, sourceType, repoPath);
|
|
356
356
|
try {
|
|
357
357
|
const result = await git.run(repoRoot, ['status', '--short', '--', moduleName]);
|
|
358
|
-
if (result.stdout.trim()) {
|
|
358
|
+
if (result.stdout.trim() && (await moduleHasCommittedFiles(repoRoot, moduleName, git))) {
|
|
359
359
|
throw new Error(`Refusing to delete module ${moduleName} because it has dirty git changes in source repo ${repoPath}.`);
|
|
360
360
|
}
|
|
361
361
|
}
|
|
@@ -365,6 +365,15 @@ async function assertModuleCleanBeforeDelete(target, sourceType, repoPath, modul
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
+
async function moduleHasCommittedFiles(repoRoot, moduleName, git) {
|
|
369
|
+
try {
|
|
370
|
+
const result = await git.run(repoRoot, ['ls-tree', '-r', '--name-only', 'HEAD', '--', moduleName]);
|
|
371
|
+
return Boolean(result.stdout.trim());
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
368
377
|
export async function addModuleToSourceRepo(options, git = realGit) {
|
|
369
378
|
const repoPath = validateRepoPath(options.repoPath);
|
|
370
379
|
const moduleName = validateModuleName(options.moduleName);
|