Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8a8e822

Browse files
committedJul 29, 2020
refactor: extract showInstructions() function
1 parent f9857f2 commit 8a8e822

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed
 

‎src/cli.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@ const createPackageJson = async (destDir, fileName) => {
122122
fs.writeFileSync(resultFile, minimalPackageJson);
123123
};
124124

125+
const showInstructions = (lang) => {
126+
console.info('The application has been generated!')
127+
if (argv.lang === 'js') {
128+
console.info(`Use
129+
npm install
130+
to install its dependencies and
131+
export DB_NAME=db DB_USER=user DB_PASSWORD=secret
132+
npm start
133+
afteward to run`);
134+
} else if (argv.lang === 'go') {
135+
console.info(`Use
136+
go run app.go
137+
or
138+
go build -o app
139+
./app
140+
to build and run it`)
141+
}
142+
};
143+
144+
125145
const argv = parseCommandLineArgs(process.argv.slice(2));
126146

127147
const config = loadConfig(endpointsFile);
@@ -141,19 +161,4 @@ if (argv.lang === 'js') {
141161
createPackageJson(destDir, 'package.json');
142162
}
143163

144-
console.info('The application has been generated!')
145-
if (argv.lang === 'js') {
146-
console.info(`Use
147-
npm install
148-
to install its dependencies and
149-
export DB_NAME=db DB_USER=user DB_PASSWORD=secret
150-
npm start
151-
afteward to run`);
152-
} else if (argv.lang === 'go') {
153-
console.info(`Use
154-
go run app.go
155-
or
156-
go build -o app
157-
./app
158-
to build and run it`)
159-
}
164+
showInstructions(argv.lang);

0 commit comments

Comments
 (0)
Please sign in to comment.