Skip to content

Commit

Permalink
[core] Don't force a remote when listing prettier changes (#18794)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored and eps1lon committed Dec 27, 2019
1 parent fec696d commit 9b39c53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test:karma": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"test:regressions": "webpack --config test/regressions/webpack.config.js && rimraf test/regressions/screenshots/chrome/* && vrtest run --config test/vrtest.config.js --record",
"test:umd": "node packages/material-ui/test/umd/run.js",
"test:unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.js' 'docs/**/*.test.js' --exclude '**/node_modules/**'",
"test:unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.js' 'docs/**/*.test.js' 'scripts/**/*.test.js' --exclude '**/node_modules/**'",
"test:watch": "yarn test:unit --watch",
"typescript": "lerna run typescript --parallel"
},
Expand Down
3 changes: 2 additions & 1 deletion scripts/listChangedFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ async function execGitCmd(args) {
}

async function listChangedFiles() {
const mergeBase = await execGitCmd(['rev-parse', 'origin/master']);
const comparedBranch = process.env.CIRCLECI ? 'origin/master' : 'master';
const mergeBase = await execGitCmd(['rev-parse', comparedBranch]);
const gitDiff = await execGitCmd(['diff', '--name-only', mergeBase]);
const gitLs = await execGitCmd(['ls-files', '--others', '--exclude-standard']);
return new Set([...gitDiff, ...gitLs]);
Expand Down
23 changes: 23 additions & 0 deletions scripts/listChangedFiles.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const listChangedFiles = require('./listChangedFiles');
const fs = require('fs');
const rimraf = require('rimraf');
const { promisify } = require('util');
const { assert } = require('chai');

const writeFileAsync = promisify(fs.writeFile);
const rimrafAsync = promisify(rimraf);

describe('listChangedFiles', () => {
it('should detect changes', async () => {
const changesBefore = await listChangedFiles();
const testFile = 'someTestFile.js';
try {
await writeFileAsync(testFile, 'console.log("hello");');
const changesAfterAdd = await listChangedFiles();
const addedFiles = Array.from(changesAfterAdd).filter(file => !changesBefore.has(file));
assert.deepEqual(addedFiles, [testFile]);
} finally {
await rimrafAsync(testFile);
}
});
});

0 comments on commit 9b39c53

Please sign in to comment.