Skip to content

Commit

Permalink
Use regex to check relative path to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdoron committed Jun 22, 2017
1 parent 18ee2fc commit be60e23
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 2 additions & 9 deletions packages/react-dev-utils/ModuleScopePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,11 @@ class ModuleScopePlugin {
path.dirname(request.context.issuer),
request.__innerRequest_request
);
const requestRelativeToRoot = path.relative(
request.descriptionFileRoot,
requestFullPath
);
if (
requestRelativeToRoot === 'package.json' ||
requestRelativeToRoot === 'package'
) {
const requestRelative = path.relative(appSrc, requestFullPath);
if (/^(..[/|\\])+package(.json)?$/.test(requestRelative)) {
return callback();
}
// Find path from src to the requested file
const requestRelative = path.relative(appSrc, requestFullPath);
// Error if in a parent directory of src/
if (
requestRelative.startsWith('../') || requestRelative.startsWith('..\\')
Expand Down
2 changes: 0 additions & 2 deletions packages/react-scripts/template/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { version, name } from '../../package.json';

class App extends Component {
render() {
Expand All @@ -10,7 +9,6 @@ class App extends Component {
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
<p>{`${name} v${version}`}</p>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
Expand Down

0 comments on commit be60e23

Please sign in to comment.