Skip to content

Commit fddd4ff

Browse files
committed
Move command definition in bin and remove obsolete main
1 parent eefbd7a commit fddd4ff

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

bin/track.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
#! /usr/bin/env node
22
import './.env.js'; // Workaround to ensure `SUPPRESS_NO_CONFIG_WARNING` is set before config is imported
33

4+
import fs from 'fs';
45
import path from 'path';
56
import { fileURLToPath, pathToFileURL } from 'url';
67

8+
import { program } from 'commander';
9+
710
const __dirname = path.dirname(fileURLToPath(import.meta.url));
811

9-
import(pathToFileURL(path.resolve(__dirname, '../src/main.js')));
12+
const { description, version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
13+
14+
program
15+
.name('ota-track')
16+
.description(description)
17+
.version(version)
18+
.option('-s, --services [serviceId...]', 'service IDs of services to handle')
19+
.option('-d, --documentTypes [documentType...]', 'terms types to handle')
20+
.option('-r, --refilter-only', 'only refilter exisiting snapshots with last declarations and engine\'s updates')
21+
.option('--schedule', 'schedule automatic document tracking');
22+
23+
const track = (await import(pathToFileURL(path.resolve(__dirname, '../src/index.js')))).default;
24+
25+
track(program.parse(process.argv).opts());

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"lint": "eslint src test scripts bin",
4242
"lint:fix": "npm run lint -- --fix",
4343
"refilter": "npm start -- --refilter-only",
44-
"start": "node --max-http-header-size=32768 src/main.js",
44+
"start": "node --max-http-header-size=32768 bin/track.js",
4545
"start:scheduler": "npm start -- --schedule",
4646
"test": "cross-env NODE_ENV=test mocha --recursive \"./src/**/*.test.js\" \"./scripts/**/*.test.js\" --exit",
4747
"posttest": "npm run lint",

src/main.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)