Skip to content

Commit 928079d

Browse files
committed
Change default name from snake_case to PascalCase
1 parent c44a80d commit 928079d

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"rollup-plugin-preserve-shebang": "^0.1.3",
5454
"rollup-plugin-sizes": "^0.4.2",
5555
"rollup-plugin-uglify": "^2.0.1",
56+
"uppercamelcase": "^3.0.0",
5657
"yargs": "^10.0.3"
5758
},
5859
"devDependencies": {

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import gzipSize from 'gzip-size';
1616
import prettyBytes from 'pretty-bytes';
1717
import shebangPlugin from 'rollup-plugin-preserve-shebang';
1818
import flow from 'rollup-plugin-flow';
19+
import pascalCase from 'uppercamelcase';
1920

2021
const readFile = promisify(fs.readFile);
2122
const stat = promisify(fs.stat);
2223
const isDir = name => stat(name).then( stats => stats.isDirectory() ).catch( () => false );
2324
const isFile = name => stat(name).then( stats => stats.isFile() ).catch( () => false );
24-
const safeVariableName = name => name.replace(/(?:^[^a-z$_]|([^a-z0-9_$]+))/g, '_');
25+
const safeVariableName = name => pascalCase(name.toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''));
2526

2627
const FORMATS = ['es', 'cjs', 'umd'];
2728

0 commit comments

Comments
 (0)