Ignore watchmanconfig in fbsource (#868)

Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/868

As discussed in D20252170

Reviewed By: passy

Differential Revision: D20278783

fbshipit-source-id: c965520a0ad44bf1838224003017177c149025e9
This commit is contained in:
Michel Weststrate
2020-03-05 08:05:10 -08:00
committed by Facebook Github Bot
parent 04acc9cfd7
commit 52b907fa25
5 changed files with 23 additions and 1 deletions

3
.gitignore vendored
View File

@@ -4,6 +4,9 @@ website/build
yarn-error.log
static/main.bundle.*
# conflicts with FB internal infra
.watchmanconfig
# iOS / Xcode
*.xcworkspace
**/Pods/

View File

@@ -11,8 +11,10 @@ import path from 'path';
import util from 'util';
import globImport from 'glob';
import {exec as execImport} from 'child_process';
import {exists as existsImport, copyFile} from 'fs';
const glob = util.promisify(globImport);
const exec = util.promisify(execImport);
const exists = util.promisify(existsImport);
const PACKAGES = [
'headless-tests',
'static',
@@ -26,6 +28,9 @@ const YARN_PATH =
? path.join(__dirname, process.argv[2])
: 'yarn' + (WINDOWS ? '.cmd' : '');
prepareWatchmanConfig(path.join(__dirname, '..'));
prepareWatchmanConfig(path.join(__dirname, '..', 'static'));
Promise.all(
PACKAGES.map(pattern =>
glob(path.join(__dirname, '..', pattern, 'package.json')),
@@ -63,3 +68,15 @@ Promise.all(
console.error(err);
process.exit(1);
});
async function prepareWatchmanConfig(dir: string) {
const hasGit = exists(path.join(__dirname, '..', '.git'));
const hasWatchmanConfig = exists(path.join(dir, '.watchmanconfig'));
if ((await hasGit) && !(await hasWatchmanConfig)) {
console.log(`Creating .watchmanconfig in ${dir}`);
await util.promisify(copyFile)(
path.join(dir, '_watchmanconfig'),
path.join(dir, '.watchmanconfig'),
);
}
}

View File

@@ -1 +0,0 @@
{}

3
static/_watchmanconfig Normal file
View File

@@ -0,0 +1,3 @@
{
"ignore_dirs": ["node_modules"]
}