Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Install typings as dev dependencies #143

Merged
merged 1 commit into from
Aug 22, 2017
Merged
Changes from all commits
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
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