Skip to content

Commit a4aba68

Browse files
committed
feat: add colors, close #3
1 parent ac5f407 commit a4aba68

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

bin/commit-message-install.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ start.then(getJsonBlock).then(json => {
2121
if (!json) {
2222
return
2323
}
24+
// alias for API simplicity
25+
json.packages = json.packages || json.package
26+
if (json.package) {
27+
delete json.package
28+
}
2429
console.log('got json block from the git commit message')
2530
console.log(JSON.stringify(json, null, 2))
2631
return npmInstall(json)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"standard": "10.0.3"
100100
},
101101
"dependencies": {
102+
"chalk": "2.3.0",
102103
"check-more-types": "2.24.0",
103104
"debug": "3.1.0",
104105
"execa": "0.8.0",

src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const la = require('lazy-ass')
66
const is = require('check-more-types')
77
const os = require('os')
88
const execa = require('execa')
9+
const chalk = require('chalk')
910

1011
const prop = name => object => object[name]
1112

@@ -103,9 +104,9 @@ function runIf (command, json) {
103104
la(isRunIf(json), 'invalid runIf json', json)
104105

105106
if (!isPlatformAllowed(json.platform, os.platform())) {
106-
console.log('Required platform: %s', json.platform)
107-
console.log('Current platform: %s', os.platform())
108-
console.log('skipping command')
107+
console.log('Required platform: %s', chalk.green(json.platform))
108+
console.log('Current platform: %s', chalk.red(os.platform()))
109+
console.log('skipping command ⏩ %s', command)
109110
return Promise.resolve()
110111
}
111112

@@ -124,9 +125,9 @@ function npmInstall (json) {
124125
la(isNpmInstall(json), 'invalid JSON to install format', json)
125126

126127
if (!isPlatformAllowed(json.platform, os.platform())) {
127-
console.log('Required platform: %s', json.platform)
128-
console.log('Current platform: %s', os.platform())
129-
console.log('skipping install')
128+
console.log('Required platform: %s', chalk.green(json.platform))
129+
console.log('Current platform: %s', chalk.red(os.platform()))
130+
console.log('skipping NPM install')
130131
return Promise.resolve()
131132
}
132133

0 commit comments

Comments
 (0)