hookstack-cli 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +4 -9
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs'
|
|
3
3
|
import { homedir } from 'os'
|
|
4
|
-
import { join } from 'path'
|
|
4
|
+
import { join, dirname } from 'path'
|
|
5
5
|
import { fileURLToPath } from 'url'
|
|
6
6
|
import * as p from '@clack/prompts'
|
|
7
7
|
import pc from 'picocolors'
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
|
|
18
18
|
const API_BASE = process.env.HOOKSTACK_API_BASE || 'https://hookstack.vercel.app'
|
|
19
19
|
const REPO_URL = 'github.com/steve-magne/hookstack'
|
|
20
|
-
const
|
|
20
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
21
|
+
const VERSION = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8')).version
|
|
21
22
|
|
|
22
23
|
async function fetchHooks(slugs) {
|
|
23
24
|
const url = `${API_BASE}/api/hooks?slugs=${slugs.map(encodeURIComponent).join(',')}`
|
|
@@ -222,7 +223,7 @@ async function main() {
|
|
|
222
223
|
const args = parseArgs(process.argv)
|
|
223
224
|
|
|
224
225
|
if (args.version) { console.log(VERSION); return }
|
|
225
|
-
if (args.help ||
|
|
226
|
+
if (args.help || args.hooks.length === 0) { console.log(HELP); return }
|
|
226
227
|
|
|
227
228
|
const command = args.command ?? 'install'
|
|
228
229
|
if (command !== 'install') {
|
|
@@ -231,12 +232,6 @@ async function main() {
|
|
|
231
232
|
process.exit(1)
|
|
232
233
|
}
|
|
233
234
|
|
|
234
|
-
if (args.hooks.length === 0) {
|
|
235
|
-
console.error('✗ No hooks specified. Use --hooks=<slug1>,<slug2>')
|
|
236
|
-
console.error(' Browse hooks at https://hookstack.vercel.app')
|
|
237
|
-
process.exit(1)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
235
|
const interactive = Boolean(process.stdout.isTTY) && !args.yes
|
|
241
236
|
if (interactive) await interactiveInstall(args.hooks, args)
|
|
242
237
|
else await directInstall(args.hooks, args)
|