Skip to content

Commit 9b60cc1

Browse files
authored
Don't pass isOnline to init script because it doesn't need it
1 parent 0a2c71a commit 9b60cc1

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

packages/create-react-app/index.js

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ function install(dependencies, verbose, isOnline) {
182182
console.log();
183183
console.error('Aborting installation.', chalk.cyan(command + ' ' + args.join(' ')), 'has failed.');
184184
reject();
185+
return;
185186
}
186-
187-
resolve(isOnline);
187+
resolve();
188188
});
189189
});
190190
}
@@ -203,53 +203,53 @@ function run(root, appName, version, verbose, originalDirectory, template) {
203203
console.log();
204204

205205
checkIfOnline()
206-
.then(function(isOnline) {
207-
return install(allDependencies, verbose, isOnline);
208-
})
209-
.then(function(isOnline) {
210-
checkNodeVersion(packageName);
211-
212-
// Since react-scripts has been installed with --save
213-
// we need to move it into devDependencies and rewrite package.json
214-
// also ensure react dependencies have caret version range
215-
fixDependencies(packageName);
216-
217-
var scriptsPath = path.resolve(
218-
process.cwd(),
219-
'node_modules',
220-
packageName,
221-
'scripts',
222-
'init.js'
223-
);
224-
var init = require(scriptsPath);
225-
init(root, appName, verbose, originalDirectory, template, isOnline);
226-
})
227-
.catch(function(command, args) {
228-
// On 'exit' we will delete these files from target directory.
229-
var knownGeneratedFiles = [
230-
'package.json', 'npm-debug.log', 'yarn-error.log', 'yarn-debug.log', 'node_modules'
231-
];
232-
var currentFiles = fs.readdirSync(path.join(root));
233-
currentFiles.forEach(function (file) {
234-
knownGeneratedFiles.forEach(function (fileToMatch) {
235-
// This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
236-
// and the rest of knownGeneratedFiles.
237-
if ((fileToMatch.match(/.log/g) && file.indexOf(fileToMatch) === 0) || file === fileToMatch) {
238-
console.log('Deleting generated file...', chalk.cyan(file));
239-
fs.removeSync(path.join(root, file));
240-
}
206+
.then(function(isOnline) {
207+
return install(allDependencies, verbose, isOnline);
208+
})
209+
.then(function() {
210+
checkNodeVersion(packageName);
211+
212+
// Since react-scripts has been installed with --save
213+
// we need to move it into devDependencies and rewrite package.json
214+
// also ensure react dependencies have caret version range
215+
fixDependencies(packageName);
216+
217+
var scriptsPath = path.resolve(
218+
process.cwd(),
219+
'node_modules',
220+
packageName,
221+
'scripts',
222+
'init.js'
223+
);
224+
var init = require(scriptsPath);
225+
init(root, appName, verbose, originalDirectory, template);
226+
})
227+
.catch(function(command, args) {
228+
// On 'exit' we will delete these files from target directory.
229+
var knownGeneratedFiles = [
230+
'package.json', 'npm-debug.log', 'yarn-error.log', 'yarn-debug.log', 'node_modules'
231+
];
232+
var currentFiles = fs.readdirSync(path.join(root));
233+
currentFiles.forEach(function (file) {
234+
knownGeneratedFiles.forEach(function (fileToMatch) {
235+
// This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
236+
// and the rest of knownGeneratedFiles.
237+
if ((fileToMatch.match(/.log/g) && file.indexOf(fileToMatch) === 0) || file === fileToMatch) {
238+
console.log('Deleting generated file...', chalk.cyan(file));
239+
fs.removeSync(path.join(root, file));
240+
}
241+
});
241242
});
243+
var remainingFiles = fs.readdirSync(path.join(root));
244+
if (!remainingFiles.length) {
245+
// Delete target folder if empty
246+
console.log('Deleting', chalk.cyan(appName + '/'), 'from', chalk.cyan(path.resolve(root, '..')));
247+
process.chdir(path.resolve(root, '..'));
248+
fs.removeSync(path.join(root));
249+
}
250+
console.log('Done.');
251+
process.exit(1);
242252
});
243-
var remainingFiles = fs.readdirSync(path.join(root));
244-
if (!remainingFiles.length) {
245-
// Delete target folder if empty
246-
console.log('Deleting', chalk.cyan(appName + '/'), 'from', chalk.cyan(path.resolve(root, '..')));
247-
process.chdir(path.resolve(root, '..'));
248-
fs.removeSync(path.join(root));
249-
}
250-
console.log('Done.');
251-
process.exit(1);
252-
});
253253
}
254254

255255
function getInstallPackage(version) {

0 commit comments

Comments
 (0)