Skip to content

Commit

Permalink
Add new cockle-config command that prints cockle version (#60)
Browse files Browse the repository at this point in the history
* Add new cockle-config command that prints cockle version

* Exclude src/version.ts from linting
  • Loading branch information
ianthomas23 authored Oct 3, 2024
1 parent d1feb64 commit 1359449
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ test/package-lock.json
*.wasm
cockle_wasm_env/
demo/package-lock.json
src/version.ts
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"lint": "npm run prettier && npm run eslint",
"lint:check": "npm run prettier:check && npm run eslint:check",
"prebuild": "node -p \"'export const COCKLE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
"prepack": "npm install && npm run fetch:wasm && npm run build",
"prettier": "prettier --list-different --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md,.yml}\""
Expand Down Expand Up @@ -58,7 +59,8 @@
"coverage",
"**/*.d.ts",
"**/*.wasm",
"**/package-lock.json"
"**/package-lock.json",
"src/version.ts"
],
"eslintConfig": {
"extends": [
Expand Down
16 changes: 16 additions & 0 deletions src/builtin/cockle_config_command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BuiltinCommand } from './builtin_command';
import { Context } from '../context';
import { ExitCode } from '../exit_code';
import { COCKLE_VERSION } from '../version';

export class CockleConfigCommand extends BuiltinCommand {
get name(): string {
return 'cockle-config';
}

protected async _run(context: Context): Promise<number> {
const { stdout } = context;
stdout.write(`cockle ${COCKLE_VERSION}\n`);
return ExitCode.SUCCESS;
}
}
1 change: 1 addition & 0 deletions src/builtin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export * from './alias_command';
export * from './builtin_command';
export * from './cd_command';
export * from './clear_command';
export * from './cockle_config_command';
export * from './export_command';
export * from './history_command';

0 comments on commit 1359449

Please sign in to comment.