UNPKG

1.55 kBJavaScriptView Raw
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15'use strict';
16
17const fs = require('fs');
18const yargs = require('yargs');
19const VersionChecker = require('./versionchecker');
20
21/**
22 * Checks the public API is in sync with changelog.txt,
23 * package.json and the public API signature
24 * @private
25 */
26let program = yargs
27 .usage('$0 [options]')
28 .options({
29 'packageJSON' : {alias: 'p', required: true, describe: 'Path of the package.json file to check', type: 'string',default:'package.json' },
30 'changelog' : {alias: 'c', required: true, describe:'Path of the chanhgelog file to check', type: 'string'},
31 'api' : {alias: 'a', required: true, describe:'API Signature file',type:'string'}
32 })
33 .argv;
34
35const changelog = fs.readFileSync(program.changelog, 'utf8');
36const publicApi = fs.readFileSync(program.api, 'utf8');
37const packageJson = fs.readFileSync(program.packageJSON, 'utf8');
38
39try {
40 VersionChecker.check(changelog, publicApi, packageJson);
41}
42catch(err) {
43 console.log(err);
44 process.exit(1);
45}