Test out Automattic/wp-calypso#3309 using the
canonical-json
module:
npm install canonical-json
node index.js
Test out Automattic/wp-calypso#3309 using the
canonical-json
module:
npm install canonical-json
node index.js
'use strict'; | |
const https = require( 'https' ); | |
JSON.stringifyCanonical = require( 'canonical-json' ); | |
// First commit in master but not the PR branch | |
const parentCommitHash = '15b8aaf'; | |
// PR branch name | |
const prBranchName = 'update/alphabetize-features'; | |
function getConfigFile( branch, filename, callback ) { | |
https.get( { | |
host: 'raw.githubusercontent.com', | |
path: '/Automattic/wp-calypso/' + branch + '/config/' + filename | |
}, res => { | |
if ( res.statusCode === 200 ) { | |
let data = ''; | |
res.on( 'data', chunk => { | |
data += chunk; | |
} ).on( 'end', () => { | |
callback( JSON.parse( data ) ); | |
} ); | |
} else { | |
throw new Error( 'HTTP ' + res.statusCode ); | |
} | |
} ); | |
} | |
[ | |
'desktop-mac-app-store.json', | |
'desktop.json', | |
'development.json', | |
'horizon.json', | |
'production.json', | |
'stage.json', | |
'wpcalypso.json' | |
].forEach( filename => { | |
getConfigFile( parentCommitHash, filename, dataUnsorted => { | |
getConfigFile( prBranchName, filename, dataSorted => { | |
const jsonUnsorted = JSON.stringifyCanonical( dataUnsorted ); | |
const jsonSorted = JSON.stringifyCanonical( dataSorted ); | |
if ( jsonUnsorted === jsonSorted && dataUnsorted.features && dataSorted.features ) { | |
console.log( 'OK: ' + filename ); | |
} else { | |
console.log( 'Not OK: ' + filename ); | |
} | |
} ); | |
} ); | |
} ); |