Skip to content

Commit

Permalink
fix: support database in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyg603 committed Apr 18, 2024
1 parent 9a5c172 commit 9cb35cc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ async function fileExists(path: string): Promise<boolean> {

async function getCommandLineOptions(argDefinitions: Array<CommandLineDefinition>): Promise<CommandLineOptions> {
const options = commandLineArgs(argDefinitions);
let { application, version } = options;
let { database, application, version } = options;
let packageJson;

if (!application || !version) {
if (!database || !application || !version) {
const packageJsonPath = './package.json';
packageJson = await fileExists(packageJsonPath) ? JSON.parse((await readFile(packageJsonPath)).toString()) : null;
}

if (!database && packageJson) {
database = packageJson.database;
}

if (!application && packageJson) {
application = packageJson.name;
}
Expand All @@ -174,6 +178,7 @@ async function getCommandLineOptions(argDefinitions: Array<CommandLineDefinition

return {
...options,
database,
application,
version
}
Expand Down

0 comments on commit 9cb35cc

Please sign in to comment.