Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5212

Don't crash npm test when hg/git are missing

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge test-git into master 6 years ago
  • Overview 2
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: gaearon

Fixes https://github.com/facebook/create-react-app/issues/5210 with a clunky workaround. I hope this more or less matches the Jest logic.

Compare
  • master (base)

and
  • latest version
    53c8a82b
    1 commit, 2 years ago

1 file
+ 22
- 1

    Preferences

    File browser
    Compare changes
packages/react-scripts/scripts/test.js
+ 22
- 1
  • View file @ 53c8a82b

  • Edit in single-file editor

  • Open in Web IDE


@@ -31,15 +31,36 @@ if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
@@ -31,15 +31,36 @@ if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
// @remove-on-eject-end
// @remove-on-eject-end
const jest = require('jest');
const jest = require('jest');
 
const execSync = require('child_process').execSync;
let argv = process.argv.slice(2);
let argv = process.argv.slice(2);
 
function isInGitRepository() {
 
try {
 
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
 
return true;
 
} catch (e) {
 
return false;
 
}
 
}
 
 
function isInMercurialRepository() {
 
try {
 
execSync('hg --cwd . root', { stdio: 'ignore' });
 
return true;
 
} catch (e) {
 
return false;
 
}
 
}
 
// Watch unless on CI, in coverage mode, or explicitly running all tests
// Watch unless on CI, in coverage mode, or explicitly running all tests
if (
if (
!process.env.CI &&
!process.env.CI &&
argv.indexOf('--coverage') === -1 &&
argv.indexOf('--coverage') === -1 &&
argv.indexOf('--watchAll') === -1
argv.indexOf('--watchAll') === -1
) {
) {
argv.push('--watch');
// https://github.com/facebook/create-react-app/issues/5210
 
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
 
argv.push(hasSourceControl ? '--watch' : '--watchAll');
}
}
// @remove-on-eject-begin
// @remove-on-eject-begin
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
CLA Signed
1
CLA Signed
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: facebook/create-react-app!596
Source branch: test-git

Menu

Explore Projects Groups Snippets