Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint untracked files with
yarn linc
(#11665)
* Lint untracked files with yarn linc (#11646) * Run prettier on untracked files * Unify code for listing changed files into shared utility
- Loading branch information
1 parent
878feeb
commit 158f040
Showing
3 changed files
with
41 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const execFileSync = require('child_process').execFileSync; | ||
|
||
const exec = (command, args) => { | ||
console.log('> ' + [command].concat(args).join(' ')); | ||
var options = { | ||
cwd: process.cwd(), | ||
env: process.env, | ||
stdio: 'pipe', | ||
encoding: 'utf-8', | ||
}; | ||
return execFileSync(command, args, options); | ||
}; | ||
const execGitCmd = args => | ||
exec('git', args) | ||
.trim() | ||
.toString() | ||
.split('\n'); | ||
|
||
const mergeBase = execGitCmd(['merge-base', 'HEAD', 'master']); | ||
|
||
const listChangedFiles = () => { | ||
return new Set([ | ||
...execGitCmd(['diff', '--name-only', '--diff-filter=ACMRTUB', mergeBase]), | ||
...execGitCmd(['ls-files', '--others', '--exclude-standard']), | ||
]); | ||
}; | ||
|
||
module.exports = listChangedFiles; |
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