Skip to content

Commit

Permalink
Merge pull request facebook#143 from swengorschewski/dependencies
Browse files Browse the repository at this point in the history
Install typings as dev dependencies
  • Loading branch information
wmonk authored Aug 22, 2017
2 parents d0d5133 + 6ae7751 commit e87df91
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ module.exports = function(
eject: 'react-scripts-ts eject',
};

console.log(appPackage);

fs.writeFileSync(
path.join(appPath, 'package.json'),
JSON.stringify(appPackage, null, 2)
Expand Down Expand Up @@ -104,6 +102,23 @@ module.exports = function(
args = ['install', '--save', verbose && '--verbose'].filter(e => e);
}

// Install dev dependencies
const types = [
'@types/node',
'@types/react',
'@types/react-dom',
'@types/jest',
];

console.log(`Installing ${types.join(', ')} as dev dependencies ${command}...`);
console.log();

const devProc = spawn.sync(command, args.concat('-D').concat(types), { stdio: 'inherit' });
if (devProc.status !== 0) {
console.error(`\`${command} ${args.concat(types).join(' ')}\` failed`);
return;
}

// Install additional template dependencies, if present
const templateDependenciesPath = path.join(
appPath,
Expand All @@ -119,22 +134,6 @@ module.exports = function(
fs.unlinkSync(templateDependenciesPath);
}

const types = [
'@types/node',
'@types/react',
'@types/react-dom',
'@types/jest',
];

console.log(`Installing ${types.join(', ')} ${command}...`);
console.log();

const proc = spawn.sync(command, args.concat(types), { stdio: 'inherit' });
if (proc.status !== 0) {
console.error(`\`${command} ${args.concat(types).join(' ')}\` failed`);
return;
}

// Install react and react-dom for backward compatibility with old CRA cli
// which doesn't install react and react-dom along with react-scripts
// or template is presetend (via --internal-testing-template)
Expand Down

0 comments on commit e87df91

Please sign in to comment.