Move safeVariableName near getName

It is only called in getName
This commit is contained in:
Matías Olivera 2018-12-25 20:54:51 -03:00
parent b696954a15
commit 3fc623a6b6

View File

@ -24,12 +24,7 @@ import { readFile, isDir, isFile, stdout, stderr } from './utils';
import camelCase from 'camelcase';
const removeScope = name => name.replace(/^@.*\//, '');
const safeVariableName = name =>
camelCase(
removeScope(name)
.toLowerCase()
.replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''),
);
const parseGlobals = globalStrings => {
const globals = {};
globalStrings.split(',').forEach(globalString => {
@ -228,6 +223,13 @@ async function getConfigFromPkgJson(cwd) {
}
}
const safeVariableName = name =>
camelCase(
removeScope(name)
.toLowerCase()
.replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''),
);
function getName({ name, pkgName, amdName, cwd, hasPackageJson }) {
if (!pkgName) {
pkgName = basename(cwd);