You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.2 KiB
77 lines
2.2 KiB
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.getProjectBabelConfigFile = getProjectBabelConfigFile;
|
|
exports.watchBabelConfig = watchBabelConfig;
|
|
exports.watchBabelConfigForProject = watchBabelConfigForProject;
|
|
function _chalk() {
|
|
const data = _interopRequireDefault(require("chalk"));
|
|
_chalk = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
function _fs() {
|
|
const data = require("fs");
|
|
_fs = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
function _path() {
|
|
const data = _interopRequireDefault(require("path"));
|
|
_path = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
function _resolveFrom() {
|
|
const data = _interopRequireDefault(require("resolve-from"));
|
|
_resolveFrom = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
function _internal() {
|
|
const data = require("../internal");
|
|
_internal = function () {
|
|
return data;
|
|
};
|
|
return data;
|
|
}
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
// List of files that are being observed.
|
|
const watchingFiles = [];
|
|
|
|
/**
|
|
* Get the babel configuration file for the project.
|
|
*/
|
|
function getProjectBabelConfigFile(projectRoot) {
|
|
return _resolveFrom().default.silent(projectRoot, './babel.config.js') || _resolveFrom().default.silent(projectRoot, './.babelrc') || _resolveFrom().default.silent(projectRoot, './.babelrc.js');
|
|
}
|
|
function watchBabelConfigForProject(projectRoot) {
|
|
const configPath = getProjectBabelConfigFile(projectRoot);
|
|
if (configPath) {
|
|
return watchBabelConfig(projectRoot, configPath);
|
|
}
|
|
return configPath;
|
|
}
|
|
|
|
/**
|
|
* Watch the babel configuration file and warn to reload the CLI if it changes.
|
|
*/
|
|
function watchBabelConfig(projectRoot, configPath) {
|
|
if (watchingFiles.includes(configPath)) {
|
|
return;
|
|
}
|
|
watchingFiles.push(configPath);
|
|
const configName = _path().default.relative(projectRoot, configPath);
|
|
(0, _fs().watchFile)(configPath, (cur, prev) => {
|
|
if (prev.size || cur.size) {
|
|
_internal().ProjectUtils.logInfo(projectRoot, 'expo', `\u203A Detected a change in ${_chalk().default.bold(configName)}. Restart the server to see the new results.`);
|
|
}
|
|
});
|
|
}
|
|
//# sourceMappingURL=watchBabelConfig.js.map
|