Skip to content

Create .babelrc file on eject #602

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

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
47 changes: 25 additions & 22 deletions scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ prompt(
var files = [
path.join('config', 'flow', 'css.js.flow'),
path.join('config', 'flow', 'file.js.flow'),
// .babelrc is generated from the dev and prod configs
path.join('config', '.babelrc'),
path.join('config', 'eslint.js'),
path.join('config', 'paths.js'),
path.join('config', 'env.js'),
Expand All @@ -49,27 +51,7 @@ prompt(
path.join('scripts', 'utils', 'WatchMissingNodeModulesPlugin.js')
];

// Ensure that the app folder is clean and we won't override any files
files.forEach(function(file) {
if (fs.existsSync(path.join(appPath, file))) {
console.error(
'`' + file + '` already exists in your app folder. We cannot ' +
'continue as you would lose all the changes in that file or directory. ' +
'Please delete it (maybe make a copy for backup) and run this ' +
'command again.'
);
process.exit(1);
}
});

// Copy the files over
fs.mkdirSync(path.join(appPath, 'config'));
fs.mkdirSync(path.join(appPath, 'config', 'flow'));
fs.mkdirSync(path.join(appPath, 'config', 'jest'));
fs.mkdirSync(path.join(appPath, 'scripts'));
fs.mkdirSync(path.join(appPath, 'scripts', 'utils'));

// Create .babelrc from dev and prod configs before dead code is removed
// Create .babelrc from dev and prod configs before copying
var babelrc = {
env: {
test: {
Expand All @@ -88,10 +70,31 @@ prompt(
};

fs.writeFileSync(
path.join(appPath, 'config', '.babelrc'),
path.join(ownPath, 'config', '.babelrc'),
Copy link
Contributor Author

@jamesblight jamesblight Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be changed so that a file isn't created in ownPath

JSON.stringify(babelrc, null, 2)
);

// Ensure that the app folder is clean and we won't override any files
files.forEach(function(file) {
if (fs.existsSync(path.join(appPath, file))) {
console.error(
'`' + file + '` already exists in your app folder. We cannot ' +
'continue as you would lose all the changes in that file or directory. ' +
'Please delete it (maybe make a copy for backup) and run this ' +
'command again.'
);
process.exit(1);
}
});

// Copy the files over
fs.mkdirSync(path.join(appPath, 'config'));
fs.mkdirSync(path.join(appPath, 'config', 'flow'));
fs.mkdirSync(path.join(appPath, 'config', 'jest'));
fs.mkdirSync(path.join(appPath, 'scripts'));
fs.mkdirSync(path.join(appPath, 'scripts', 'utils'));


files.forEach(function(file) {
console.log('Copying ' + file + ' to ' + appPath);
var content = fs
Expand Down