-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Don't force a remote when listing prettier changes (#18794)
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
}); |