mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add resolve check before addon add
This commit is contained in:
1 parent
6a4aa14016
commit
3e918346ff
3 files changed
+21
-4
No files matched your search
@@ -111,7 +111,15 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
|
||||
}
|
||||
}
|
||||
|
||||
if (operation === 'add' && name) addons.push(name);
|
||||
if (operation === 'add' && name) {
|
||||
try {
|
||||
require.resolve(`${name}/package.json`);
|
||||
} catch (e) {
|
||||
console.error(`Addon not found or not available: ${name}`);
|
||||
return;
|
||||
}
|
||||
addons.push(name);
|
||||
}
|
||||
addons = Array.from(new Set(addons));
|
||||
console.log('Current Addons: ', addons);
|
||||
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
||||
|
||||
Reference in new issue
Block a user