Change the index file format to use "export ... from" (fixes #3)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import yargs from 'yargs';
|
||||
import writeIndex from './../writeIndex';
|
||||
import {
|
||||
writeIndex
|
||||
} from './../utilities';
|
||||
|
||||
let argv;
|
||||
|
||||
|
||||
+1
-9
@@ -1,14 +1,6 @@
|
||||
'create index';
|
||||
|
||||
import createIndexCode from './createIndexCode.js';
|
||||
import readDirectory from './readDirectory.js';
|
||||
import validateTargetDirectory from './validateTargetDirectory.js';
|
||||
import writeIndex from './writeIndex.js';
|
||||
|
||||
export {
|
||||
createIndexCode,
|
||||
readDirectory,
|
||||
validateTargetDirectory,
|
||||
writeIndex
|
||||
};
|
||||
|
||||
} from './utilities';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
let buildExportBlock,
|
||||
buildImportBlock,
|
||||
safeVariableName;
|
||||
|
||||
safeVariableName = (fileName) => {
|
||||
@@ -16,11 +15,11 @@ safeVariableName = (fileName) => {
|
||||
}
|
||||
};
|
||||
|
||||
buildImportBlock = (files) => {
|
||||
buildExportBlock = (files) => {
|
||||
let importBlock;
|
||||
|
||||
importBlock = _.map(files, (fileName) => {
|
||||
return 'import ' + safeVariableName(fileName) + ' from \'./' + fileName + '\';';
|
||||
return 'export ' + safeVariableName(fileName) + ' from \'./' + fileName + '\';';
|
||||
});
|
||||
|
||||
importBlock = importBlock.join('\n');
|
||||
@@ -28,18 +27,6 @@ buildImportBlock = (files) => {
|
||||
return importBlock;
|
||||
};
|
||||
|
||||
buildExportBlock = (files) => {
|
||||
let exportBlock;
|
||||
|
||||
exportBlock = _.map(files, (fileName) => {
|
||||
return ' ' + safeVariableName(fileName);
|
||||
});
|
||||
|
||||
exportBlock = 'export {\n' + exportBlock.join(',\n') + '\n};';
|
||||
|
||||
return exportBlock;
|
||||
};
|
||||
|
||||
export default (filePaths) => {
|
||||
let code,
|
||||
sortedFilePaths;
|
||||
@@ -49,7 +36,7 @@ export default (filePaths) => {
|
||||
if (filePaths.length) {
|
||||
sortedFilePaths = filePaths.sort();
|
||||
|
||||
code += buildImportBlock(sortedFilePaths) + '\n\n' + buildExportBlock(sortedFilePaths) + '\n\n';
|
||||
code += buildExportBlock(sortedFilePaths) + '\n\n';
|
||||
}
|
||||
|
||||
return code;
|
||||
@@ -0,0 +1,8 @@
|
||||
'create index';
|
||||
|
||||
export createIndexCode from './createIndexCode.js';
|
||||
export readDirectory from './readDirectory.js';
|
||||
export sortByDepth from './sortByDepth.js';
|
||||
export validateTargetDirectory from './validateTargetDirectory.js';
|
||||
export writeIndex from './writeIndex.js';
|
||||
|
||||
Reference in New Issue
Block a user