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
  • !1590

Support node scripts in BROWSER

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/GAumala/node-scripts-browser into master Feb 20, 2017
  • Overview 15
  • Commits 4
  • Pipelines 0
  • Changes 3

Created by: GAumala

Modify OpenBrowser.js to run node scripts specified with the BROWSER environment variable as discussed in #1533 (closed) . If the value of the BROWSER environment variable ends with '.js' a child process is spawned to execute the script with node.js. The command executed in the child process is 'node PATH_SCRIPT'.

Some observations I'd like to discuss:

  • Since BROWSER now does more than just opening your browser, maybe we should consider renaming a few things.
  • The string argument of the script to run with node is not sanitized in any way. Nothing is checked, the string is passed to the child process as is. I don't know what is the worst thing that could happen. Scripts ending in '.JS' are not executed.
  • The openBrowser() function returns a boolean. I decided to stick with this behavior, but I noticed that the result is not used in react-scripts/scripts/start.js.

How to test this:

create any 'script.js' file. You can use this one that writes a file to the current working directory:

const fs = require('fs')

fs.writeFileSync('message.txt', 'script says hello!');

Now in the same directory execute:

BROWSER=script.js npm start

The file should be created in that directory and no browser should be opened.

And of course, the other use cases of BROWSER still work

BROWSER=none npm start
BROWSER=firefox npm start

Any feedback is appreciated.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/GAumala/node-scripts-browser