napi-rs/cli/src/index.ts

35 lines
802 B
TypeScript
Raw Normal View History

2020-08-21 22:28:10 +08:00
#!/usr/bin/env node
2020-07-26 23:53:09 +08:00
import { Cli } from 'clipanion'
2020-09-04 16:22:15 +08:00
import { ArtifactsCommand } from './artifacts'
2020-07-26 23:53:09 +08:00
import { BuildCommand } from './build'
2020-09-04 16:22:15 +08:00
import { CreateNpmDirCommand } from './create-npm-dir'
2020-12-16 00:04:11 +08:00
import { NewProjectCommand } from './new'
2020-09-04 16:22:15 +08:00
import { PrePublishCommand } from './pre-publish'
import { VersionCommand } from './version'
2020-07-26 23:53:09 +08:00
const cli = new Cli({
2020-12-23 22:43:43 +08:00
binaryName: 'napi',
2020-07-26 23:53:09 +08:00
binaryVersion: require('../package.json').version,
})
2020-09-04 16:22:15 +08:00
cli.register(ArtifactsCommand)
2020-07-26 23:53:09 +08:00
cli.register(BuildCommand)
2020-09-04 16:22:15 +08:00
cli.register(CreateNpmDirCommand)
2020-12-16 00:04:11 +08:00
cli.register(NewProjectCommand)
2020-09-04 16:22:15 +08:00
cli.register(PrePublishCommand)
cli.register(VersionCommand)
2020-07-26 23:53:09 +08:00
cli
.run(process.argv.slice(2), {
...Cli.defaultContext,
})
2020-09-04 16:22:15 +08:00
.then((status) => {
process.exit(status)
})
2020-07-26 23:53:09 +08:00
.catch((e) => {
console.error(e)
process.exit(1)
})