Skip to content
GitLab
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
  • !9052

Fix chained npm scripts yarn

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/tomvalorsa/fix-chained-npm-scripts-yarn into master May 23, 2020
  • Overview 8
  • Commits 2
  • Pipelines 0
  • Changes 3

Created by: tomvalorsa

This PR adds a small fix to ensure that all npm scripts in template.json are converted to yarn correctly. Previously with scripts that had chained commands (i.e. npm run this && npm run that) only the first instance of npm/npm run would be replaced with yarn. This is to address #8795 (closed) (which has since been closed/locked as I forgot to keep it alive with another comment - sorry for any inconvenience!).

  • 1st commit adds a global flag to the regex that handles the replacing to fix this issue
  • 2nd commit splits the replace function out into a util and adds some tests, as I felt a bit cheeky making a 1 char PR :)

N.B. the tests in the second commit have been placed near the code in question, but I’m happy to move them to wherever suits. I could only get these tests to run by passing the path to jest specifically, so I get the feeling that they sit outside of the normal test setup of this repo.

To run tests from root dir I used:

npx jest ./packages/react-scripts/scripts/utils/__tests__/replaceNpmScriptsWithYarn.test.js

Result: image

(reverting to the original code without the g flag breaks the second test as expected)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/tomvalorsa/fix-chained-npm-scripts-yarn