Commit f8b47260 authored by Dan Abramov's avatar Dan Abramov
Browse files

Add missing file check to npm run build too

parent 4a0f39ae
No related merge requests found
Showing with 38 additions and 15 deletions
+38 -15
......@@ -21,9 +21,12 @@ var rimrafSync = require('rimraf').sync;
var webpack = require('webpack');
var config = require('../config/webpack.config.prod');
var paths = require('../config/paths');
var checkRequiredFiles = require('./utils/checkRequiredFiles');
var recursive = require('recursive-readdir');
var stripAnsi = require('strip-ansi');
checkRequiredFiles();
// Input: /User/dan/app/build/static/js/main.82be8.js
// Output: /static/js/main.js
function removeFileNameHash(fileName) {
......
......@@ -44,6 +44,7 @@ prompt(
path.join('config', 'jest', 'transform.js'),
path.join('scripts', 'build.js'),
path.join('scripts', 'start.js'),
path.join('scripts', 'utils', 'checkRequiredFiles.js'),
path.join('scripts', 'utils', 'chrome.applescript'),
path.join('scripts', 'utils', 'prompt.js'),
path.join('scripts', 'utils', 'WatchMissingNodeModulesPlugin.js')
......
......@@ -11,7 +11,6 @@
process.env.NODE_ENV = 'development';
var fs = require('fs');
var path = require('path');
var chalk = require('chalk');
var webpack = require('webpack');
......@@ -21,6 +20,7 @@ var httpProxyMiddleware = require('http-proxy-middleware');
var execSync = require('child_process').execSync;
var opn = require('opn');
var detect = require('detect-port');
var checkRequiredFiles = require('./utils/checkRequiredFiles');
var prompt = require('./utils/prompt');
var config = require('../config/webpack.config.dev');
var paths = require('../config/paths');
......@@ -171,20 +171,6 @@ function openBrowser(port, protocol) {
opn(protocol + '://localhost:' + port + '/');
}
function checkRequiredFiles() {
var filesPathToCheck = [paths.appHtml, paths.appIndexJs];
filesPathToCheck.forEach(function(filePath) {
try {
fs.accessSync(filePath, fs.F_OK);
} catch (err) {
var fileName = path.basename(filePath);
console.log(
chalk.red(`Cannot find ${fileName} in ${filePath} directory`)
);
process.exit(1);
}
});
}
// We need to provide a custom onError function for httpProxyMiddleware.
// It allows us to log custom error messages on the console.
function onProxyError(proxy) {
......
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @remove-on-eject-end
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const paths = require('../../config/paths');
function checkRequiredFiles() {
const filesPathToCheck = [paths.appHtml, paths.appIndexJs];
filesPathToCheck.forEach(filePath => {
try {
fs.accessSync(filePath, fs.F_OK);
} catch (err) {
const dirName = path.dirname(filePath);
const fileName = path.basename(filePath);
console.log(chalk.red('Could not find a required file.'));
console.log(chalk.red(' Name: ') + chalk.cyan(fileName));
console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName));
process.exit(1);
}
});
}
module.exports = checkRequiredFiles;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment