Skip to content
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

[WIP] Make yarn workspaces work #3435

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
22 changes: 9 additions & 13 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
const url = require('url');
const hyperquest = require('hyperquest');
const resolveFrom = require('resolve-from');

const packageJson = require('./package.json');

Expand Down Expand Up @@ -292,15 +293,12 @@ function run(
);
})
.then(packageName => {
checkNodeVersion(packageName);
checkNodeVersion(root, packageName);
setCaretRangeForRuntimeDeps(packageName);

const scriptsPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'scripts',
'init.js'
const scriptsPath = resolveFrom(
root,
path.join(packageName, 'scripts', 'init.js')
);
const init = require(scriptsPath);
init(root, appName, verbose, originalDirectory, template);
Expand Down Expand Up @@ -478,12 +476,10 @@ function checkNpmVersion() {
};
}

function checkNodeVersion(packageName) {
const packageJsonPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'package.json'
function checkNodeVersion(root, packageName) {
const packageJsonPath = resolveFrom(
root,
path.join(packageName, 'package.json')
);
const packageJson = require(packageJsonPath);
if (!packageJson.engines || !packageJson.engines.node) {
Expand Down
1 change: 1 addition & 0 deletions packages/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"cross-spawn": "^4.0.0",
"fs-extra": "^1.0.0",
"hyperquest": "^2.1.2",
"resolve-from": "^4.0.0",
"semver": "^5.0.3",
"tar-pack": "^3.4.0",
"tmp": "0.0.31",
Expand Down
6 changes: 5 additions & 1 deletion packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const fs = require('fs-extra');
const path = require('path');
const chalk = require('chalk');
const spawn = require('react-dev-utils/crossSpawn');
const resolveFrom = require('resolve-from');

module.exports = function(
appPath,
Expand All @@ -28,7 +29,10 @@ module.exports = function(
) {
const ownPackageName = require(path.join(__dirname, '..', 'package.json'))
.name;
const ownPath = path.join(appPath, 'node_modules', ownPackageName);
const ownPath = path.join(
resolveFrom(appPath, path.join(ownPackageName, 'package.json')),
'..'
);
const appPackage = require(path.join(appPath, 'package.json'));
const useYarn = fs.existsSync(path.join(appPath, 'yarn.lock'));

Expand Down