21 lines
704 B
TypeScript
21 lines
704 B
TypeScript
import { getManifest, IManifest, Product, verifyProductName } from 'ssn';
|
|
import failWithError from './failWithError';
|
|
|
|
const failFunction = failWithError.bind(null, 'node dist/getManifest.js <product>');
|
|
|
|
if (process.argv.length !== 3) {
|
|
failFunction(`Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`);
|
|
}
|
|
|
|
//Check that product name is valid
|
|
const product = process.argv[2];
|
|
if (!verifyProductName(product)) {
|
|
failFunction(`"${product} is not a valid product name.`);
|
|
}
|
|
|
|
//Get manifest and write output to stdout
|
|
getManifest(product as Product).then((output: IManifest) => {
|
|
process.stdout.write(JSON.stringify(output));
|
|
}).catch((error) => {
|
|
failFunction(error);
|
|
});
|