Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Don't force a remote when listing prettier changes #18794

Merged
merged 8 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
});
});