-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add esbuild command for testing
- Loading branch information
1 parent
b8a9f77
commit c1b18ac
Showing
6 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {Args, Command, Flags, Interfaces} from '@oclif/core' | ||
|
||
type Result = { | ||
args: Interfaces.InferredArgs<typeof ESBuild.args> | ||
flags: Interfaces.InferredFlags<typeof ESBuild.flags> | ||
} | ||
|
||
export default class ESBuild extends Command { | ||
static args = { | ||
defaultArg: Args.string({ | ||
default: 'simple string default', | ||
}), | ||
defaultFnArg: Args.string({ | ||
default: async () => 'async fn default', | ||
}), | ||
optionalArg: Args.string(), | ||
} | ||
|
||
static enableJsonFlag = true | ||
|
||
static flags = { | ||
defaultFnString: Flags.string({ | ||
default: async () => 'async fn default', | ||
}), | ||
defaultString: Flags.string({ | ||
default: 'simple string default', | ||
}), | ||
optionalString: Flags.string(), | ||
} | ||
|
||
async run(): Promise<Result> { | ||
const {args, flags} = await this.parse(ESBuild) | ||
this.log(`hello I am a bundled (esbuild) plugin from ${this.config.root}!`) | ||
return {args, flags} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {Hook} from '@oclif/core' | ||
import {Hook, ux} from '@oclif/core' | ||
|
||
const hook: Hook<'init'> = async function (opts) { | ||
process.stdout.write(`example hook running ${opts.id}\n`) | ||
const hook: Hook<'init'> = async function () { | ||
ux.log('Greetings! from plugin-test-esbuild init hook') | ||
} | ||
|
||
export default hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {expect, test} from '@oclif/test' | ||
|
||
describe('esbuild', () => { | ||
test | ||
.stdout() | ||
.command(['esbuild']) | ||
.it('runs esbuild cmd', (ctx) => { | ||
expect(ctx.stdout).to.contain('hello I am a bundled (esbuild) plugin') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters