mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: cli: detect mongosh
This commit is contained in:
1 parent
092c0ee4eb
commit
aac27b3f83
1 file changed
+8
-1
@@ -60,7 +60,14 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
|
||||
cli.command('db').action(() => {
|
||||
const dbConfig = fs.readFileSync(path.resolve(hydroPath, 'config.json'), 'utf-8');
|
||||
const url = buildUrl(JSON.parse(dbConfig));
|
||||
child.spawn('mongo', [url], { stdio: 'inherit' });
|
||||
try {
|
||||
console.log('Detecting mongosh...');
|
||||
const mongosh = child.execSync('mongosh --version').toString();
|
||||
if (/\d+\.\d+\.\d+/.test(mongosh)) child.spawn('mongosh', [url], { stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
console.log('Cannot run mongosh. Trying legacy mongo client...');
|
||||
child.spawn('mongo', [url], { stdio: 'inherit' });
|
||||
}
|
||||
});
|
||||
cli.command('backup').action(() => {
|
||||
const dbConfig = fs.readFileSync(path.resolve(hydroPath, 'config.json'), 'utf-8');
|
||||
|
||||
Reference in new issue
Block a user