Skip to content

Commit

Permalink
feat: use oclif/core (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
RasPhilCo authored Sep 24, 2021
1 parent 42cd611 commit f9f9981
Show file tree
Hide file tree
Showing 6 changed files with 2,096 additions and 44 deletions.
18 changes: 18 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const oclif = require('@oclif/core')

const path = require('path')
const project = path.join(__dirname, '..', 'tsconfig.json')

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development'

require('ts-node').register({project})

// In dev mode, always show stack traces
// Waiting for https://github.com/oclif/core/pull/147
// oclif.settings.debug = true;

// Start the CLI
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
3 changes: 3 additions & 0 deletions bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
5 changes: 3 additions & 2 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

require('@oclif/command').run()
.catch(require('@oclif/errors/handle'))
const oclif = require('@oclif/core')

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/oclif/plugin-which/issues",
"dependencies": {
"@oclif/command": "^1.5.4",
"@oclif/config": "^1.8.7",
"@oclif/core": "^0.5.39",
"cli-ux": "^5.4.7",
"tslib": "^2.0.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1.19.1",
"@oclif/plugin-help": "^3.1.0",
"@oclif/plugin-help": "^5.1.0",
"@oclif/test": "^1.2.1",
"@types/chai": "^4.1.6",
"@types/mocha": "^8.0.0",
Expand All @@ -24,6 +22,7 @@
"globby": "^11",
"mocha": "^8",
"nyc": "^15.1.0",
"oclif": "^2.0.0-main.5",
"ts-node": "^9.0.0",
"typescript": "4.4.3"
},
Expand All @@ -50,9 +49,9 @@
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"posttest": "yarn lint",
"prepack": "yarn build && oclif-dev manifest && oclif-dev readme",
"prepack": "yarn build && oclif manifest && oclif readme",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md",
"version": "oclif readme && git add README.md",
"lint": "eslint . --ext .ts --config .eslintrc",
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
"build": "rm -rf lib && tsc"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/which.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command} from '@oclif/command'
import {Command} from '@oclif/core'
import ux from 'cli-ux'

export default class Which extends Command {
Expand All @@ -7,7 +7,7 @@ export default class Which extends Command {
static args = [{name: 'command', required: true}]

async run() {
const {args} = this.parse(Which)
const {args} = await this.parse(Which)
const cmd = this.config.findCommand(args.command, {must: true})
ux.styledHeader(cmd.id)
ux.styledObject({
Expand Down
Loading

0 comments on commit f9f9981

Please sign in to comment.