Replace diff function in `getFilesChangedInPR` and small fix (#11)

* `structuralDiff` in `getFilesChangedInPR` instead of `diff`

* fix '@types/jsonpath' and result for exec function

* bump version small fix
This commit is contained in:
ruowan 2019-07-11 08:11:23 +08:00 коммит произвёл Sergey Shandar
Родитель b273baf1be
Коммит 3da86fe62e
4 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -1,5 +1,11 @@
# Changelog
## 0.4.0
- fix exec function
- replace diff with structural diff
- add package '@types/jsonpath'
## 0.3.9
- remove global variables

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "@azure/rest-api-specs-scripts",
"version": "0.3.9",
"version": "0.4.0",
"description": "Scripts for the Azure RestAPI specification repository 'azure-rest-api-specs'.",
"types": "dist/index.d.ts",
"main": "dist/index.js",
@ -27,6 +27,7 @@
"@types/fs-extra": "^5.0.5",
"@types/glob": "^7.1.1",
"@types/js-yaml": "^3.12.1",
"@types/jsonpath": "^0.2.0",
"@types/node": "^11.13.6",
"@types/request": "^2.48.1",
"typescript": "^3.4.4"

Просмотреть файл

@ -20,14 +20,14 @@ const exec = (cmd: string, options?: cp.SpawnSyncOptions) => {
export async function main() {
const pr = await devOps.createPullRequestProperties(cli.defaultConfig())
const swaggersToProcess = await utils.getFilesChangedInPR(pr);
let result = 0
let result: number = 0
for (const swagger of swaggersToProcess) {
try {
// await oav.validateExamples(swagger, null, {consoleLogLevel: 'error', pretty: true});
// run OAV as a separate process to avoid memory issues.
const r = exec(`node node_modules/oav/dist/cli.js validate-example ${swagger} --pretty`)
if (result === 0) {
result = r
result = r === null ? 1 : r
}
} catch (e) {
console.error("error: ")

Просмотреть файл

@ -236,7 +236,7 @@ export const getConfigFilesChangedInPR = async (pr: devOps.PullRequestProperties
console.log(filesChanged);
// traverse up to readme.md files
const configFiles = new Set();
const configFiles = new Set<string>();
for (let fileChanged of filesChanged) {
while (fileChanged.startsWith("specification")) {
if (fileChanged.toLowerCase().endsWith("readme.md") && fs.existsSync(fileChanged)) {
@ -273,7 +273,7 @@ export const getFilesChangedInPR = async (pr: devOps.PullRequestProperties | und
let result = getSwaggers();
if (pr !== undefined) {
try {
let filesChanged = (await pr.diff()).map(file => file.path)
let filesChanged = (await pr.structuralDiff().toArray())
console.log('>>>>> Files changed in this PR are as follows:')
console.log(filesChanged);
let swaggerFilesInPR = filesChanged.filter(function (item: string) {