Skip to content

Commit a745e73

Browse files
author
hirsch88
committed
Add banner to the npm main scripts
1 parent 1ac0bbe commit a745e73

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@
44
"description": "A delightful way to building a RESTful API with NodeJs & TypeScript",
55
"main": "src/app.ts",
66
"scripts": {
7+
"banner": "./node_modules/.bin/ts-node --fast ./src/console/lib/banner.ts",
78
"pretest": "./node_modules/.bin/tslint -c ./tslint.json -t stylish './test/unit/**/*.ts'",
8-
"test": "NODE_ENV=test ./node_modules/.bin/jest ./test/unit",
9+
"test": "npm run banner test && NODE_ENV=test ./node_modules/.bin/jest ./test/unit",
910
"test:pretty": "npm run test -- --verbose",
1011
"test:coverage": "npm run test -- --coverage",
1112
"pretest:black-box": "./node_modules/.bin/tslint -c ./tslint.json -t stylish './test/black-box/**/*.ts'",
12-
"test:black-box": "NODE_ENV=test ./node_modules/.bin/jest ./test/black-box -i",
13+
"test:black-box": "npm run banner test && NODE_ENV=test ./node_modules/.bin/jest ./test/black-box -i",
1314
"test:black-box:pretty": "npm run test:black-box -- --verbose",
1415
"lint": "./node_modules/.bin/tslint -c ./tslint.json -p tsconfig.json 'src/**/*.ts' --format stylish",
15-
"build": "npm run lint && npm run clean:dist && npm run transpile && npm run copy:assets",
16+
"build": "npm run banner build && npm run lint && npm run clean:dist && npm run transpile && npm run copy:assets",
1617
"transpile": "./node_modules/.bin/tsc",
1718
"clean:dist": "./node_modules/.bin/rimraf ./dist",
1819
"copy:assets": "npm run copy:swagger && npm run copy:public",
1920
"copy:swagger": "./node_modules/.bin/copyup ./src/api/swagger.json ./dist",
2021
"copy:public": "./node_modules/.bin/copyup ./src/public/* ./dist",
21-
"db:migrate": "./node_modules/.bin/knex migrate:latest",
22-
"db:migrate:rollback": "./node_modules/.bin/knex migrate:rollback",
23-
"db:seed": "./node_modules/.bin/knex seed:run",
22+
"db:migrate": "npm run banner migrate && ./node_modules/.bin/knex migrate:latest",
23+
"db:migrate:rollback": "npm run banner rollback && ./node_modules/.bin/knex migrate:rollback",
24+
"db:seed": "npm run banner seed && ./node_modules/.bin/knex seed:run",
2425
"db:reset": "npm run console db:reset",
2526
"console": "./node_modules/.bin/ts-node --fast ./src/console/commander.ts",
2627
"console:dev": "./node_modules/.bin/ts-node ./src/console/commander.ts",
2728
"console:help": "./node_modules/.bin/ts-node --fast ./src/console/commander.ts --help",
28-
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts' --watch 'src/**/*.json' --watch '.env'",
29+
"serve": "npm run banner serve && ./node_modules/.bin/nodemon --watch 'src/**/*.ts' --watch 'src/**/*.json' --watch '.env'",
2930
"start": "node dist/app.js"
3031
},
3132
"repository": "git+ssh://git@github.com/w3tec/express-typescript-boilerplate.git",

src/console/lib/banner.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as figlet from 'figlet';
2+
import * as chalk from 'chalk';
3+
4+
5+
figlet(process.argv[2], (error: any, data: any) => {
6+
if (error) {
7+
return process.exit(1);
8+
}
9+
console.log(chalk.blue(data));
10+
console.log('');
11+
process.exit(0);
12+
});

0 commit comments

Comments
 (0)