Skip to content

Commit

Permalink
Added --version flag (fixes #60) (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeManSu authored Jul 29, 2024
1 parent a97dccf commit d84c7fd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.1.0",
"description": "Reimplementation of MetaCall FaaS platform written in TypeScript.",
"main": "dist/index.js",
"bin": {
"metacall-faas": "dist/index.js"
},
"scripts": {
"test": "npm run build && mocha dist/test",
"prepublishOnly": "npm run build",
Expand Down Expand Up @@ -100,7 +103,6 @@
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unsafe-return": "off"

}
}
]
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#!/usr/bin/env node

import colors from 'colors';
import dotenv from 'dotenv';

import { initializeAPI } from './api';
import { autoDeployApps } from './utils/autoDeploy';
import { appsDirectory } from './utils/config';
import { ensureFolderExists } from './utils/filesystem';
import { printVersionAndExit } from './utils/version';

// Initialize the FaaS
void (async (): Promise<void> => {
try {
const args = process.argv.slice(2);
if (args.includes('--version')) {
printVersionAndExit();
}

dotenv.config();
colors.enable();

Expand Down
11 changes: 11 additions & 0 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readFileSync } from 'fs';
import { join } from 'path';

export function printVersionAndExit(): void {
const packageJsonPath = join(__dirname, '../../package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
version: string;
};
console.log(`FaaS version: ${packageJson.version}`);
process.exit(0);
}

0 comments on commit d84c7fd

Please sign in to comment.