Skip to content

Commit b0f580b

Browse files
James TsaiJames Tsai
authored andcommitted
feat: update bin/dev and bin/run cmd for v2 oclif usage
1 parent 94e3933 commit b0f580b

5 files changed

Lines changed: 23 additions & 16 deletions

File tree

bin/dev

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const oclif = require('@oclif/core')
4+
5+
const path = require('path')
6+
const project = path.join(__dirname, '..', 'tsconfig.json')
7+
8+
// In dev mode -> use ts-node and dev plugins
9+
process.env.NODE_ENV = 'development'
10+
11+
require('ts-node').register({project})
12+
13+
// In dev mode, always show stack traces
14+
oclif.settings.debug = true;
15+
16+
// Start the CLI
17+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)

bin/dev.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\dev" %*

bin/run

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs')
4-
const path = require('path')
5-
const project = path.join(__dirname, '../tsconfig.json')
6-
const dev = fs.existsSync(project)
3+
const oclif = require('@oclif/core')
74

8-
if (process.env.NODE_ENV === 'development') {
9-
require('dotenv').config()
10-
}
11-
12-
if (dev) {
13-
require('ts-node').register({project})
14-
}
15-
16-
require(`../${dev ? 'src' : 'lib'}`).run()
17-
.then(require('@oclif/command/flush'))
18-
.catch(require('@oclif/errors/handle'))
5+
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))

bin/run.cmd

100644100755
File mode changed.

src/commands/notes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Command, Flags, CliUx } from '@oclif/core'
22
import {APIClient} from '../../api'
33

44
export default class IndexCommand extends Command {
5-
static description = 'List user notes'
5+
static description = 'HackMD notes commands'
66

77
static examples = [
88
`$ hackmd-cli notes

0 commit comments

Comments
 (0)