From 3fc623a6b64d14597a2f23d64cf2f3cf521e276e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Olivera?= Date: Tue, 25 Dec 2018 20:54:51 -0300 Subject: [PATCH] Move safeVariableName near getName It is only called in getName --- src/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 54d0ea6..4896394 100644 --- a/src/index.js +++ b/src/index.js @@ -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);