Skip to content

Commit

Permalink
Convert underscore files to dotfiles (as in RN CLI)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglowder committed May 11, 2023
1 parent 0350c7b commit 7ad6258
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/createFileTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ class Transformer extends Minipass {
}
}

// Files and directories that have `_` as their first character in React Native CLI templates
// These should be transformed to have `.` as the first character
const UNDERSCORED_DOTFILES = [
'buckconfig',
'eslintrc.js',
'flowconfig',
'gitattributes',
'gitignore',
'prettierrc.js',
'watchmanconfig',
'editorconfig',
'bundle',
'ruby-version',
'node-version',
'xcode.env',
];

export function createEntryResolver(name: string) {
return (entry: ReadEntry) => {
if (name) {
Expand All @@ -46,6 +63,9 @@ export function createEntryResolver(name: string) {
// See: https://github.com/npm/npm/issues/1862
entry.path = entry.path.replace(/gitignore$/, '.gitignore');
}
for (const fileName of UNDERSCORED_DOTFILES) {
entry.path = entry.path.replace(`_${fileName}`, `.${fileName}`);
}
};
}

Expand Down

0 comments on commit 7ad6258

Please sign in to comment.