ssn/src/getManifest.ts

29 lines
891 B
TypeScript
Raw Normal View History

import IManifest from './interfaces/IManifest';
import { Product } from './interfaces/ISettings';
import getManifest from './ssn/getManifest';
import verifyProductName from './ssn/verify/verifyProductName';
function failWithError(msg?: string) {
if (msg !== undefined) {
process.stderr.write(msg);
}
process.stderr.write('Usage: node dist/getManifest.js <product>');
process.exit(1);
}
if (process.argv.length !== 2) {
failWithError(`Error: Expected 1 argument but ${process.argv.length - 1} arguments were supplied.`);
}
//Check that product name is valid
const product = process.argv[1];
if (!verifyProductName(product)) {
failWithError(`Error: "${product} is not a valid product name.`);
}
//Get manifest and write output to console
getManifest(product as Product).then((output: IManifest) => {
process.stdout.write(JSON.stringify(output));
//process.exit(0);
});