Skip to content

Commit

Permalink
feat: add init hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 9, 2023
1 parent e805e10 commit f183b73
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"hello": {
"description": "Say hello to the world and others"
}
},
"hooks": {
"init": "./dist/hooks/init/init"
}
},
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/init/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {Hook} from '@oclif/core'

const hook: Hook<'init'> = async function () {
console.log('Greetings! from plugin-test-esm-1 init hook')
}

export default hook
9 changes: 9 additions & 0 deletions test/hooks/init/init.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {expect, test} from '@oclif/test'

describe('hooks', () => {
test
.stdout()
.hook('init', {id: 'mycommand'})
.do(output => expect(output.stdout).to.contain('Greetings!'))
.it('shows a message')
})

0 comments on commit f183b73

Please sign in to comment.