style: fix code style
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import yargs from 'yargs';
|
||||
import {
|
||||
writeIndexCli
|
||||
} from './../utilities';
|
||||
} from '../utilities';
|
||||
|
||||
const argv = yargs
|
||||
.demand(1)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
import validateTargetDirectory from './validateTargetDirectory';
|
||||
|
||||
export default (directoryPath) => {
|
||||
@@ -13,11 +13,11 @@ export default (directoryPath) => {
|
||||
validateTargetDirectory(path.dirname(targetDirectoryPath));
|
||||
|
||||
return true;
|
||||
/* eslint-disable no-empty */
|
||||
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -4,5 +4,6 @@ import moment from 'moment';
|
||||
export default (...append) => {
|
||||
/* eslint-disable no-console */
|
||||
console.log(chalk.dim('[' + moment().format('HH:mm:ss') + ']'), ...append);
|
||||
|
||||
/* eslint-enable no-console */
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import _ from 'lodash';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import validateTargetDirectory from './validateTargetDirectory';
|
||||
|
||||
const hasIndex = (directoryPath) => {
|
||||
@@ -28,7 +28,7 @@ const hasMultipleExtensions = (fileName) => {
|
||||
};
|
||||
|
||||
const isSafeName = (fileName) => {
|
||||
return /^[a-z][a-z0-9\._]+$/i.test(fileName);
|
||||
return /^[a-z][a-z0-9._]+$/i.test(fileName);
|
||||
};
|
||||
|
||||
const removeDuplicates = (files) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default (targetDirectory) => {
|
||||
let stats;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import createIndexCode from './createIndexCode';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import createIndexCode from './createIndexCode';
|
||||
import validateTargetDirectory from './validateTargetDirectory';
|
||||
import readDirectory from './readDirectory';
|
||||
import sortByDepth from './sortByDepth';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import _ from 'lodash';
|
||||
import createIndexCode from './createIndexCode';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import chalk from 'chalk';
|
||||
import createIndexCode from './createIndexCode';
|
||||
import validateTargetDirectory from './validateTargetDirectory';
|
||||
import readDirectory from './readDirectory';
|
||||
import sortByDepth from './sortByDepth';
|
||||
import log from './log';
|
||||
import findIndexFiles from './findIndexFiles';
|
||||
import chalk from 'chalk';
|
||||
|
||||
export default (directoryPaths, options = {}) => {
|
||||
let sortedDirectoryPaths;
|
||||
@@ -41,10 +41,12 @@ export default (directoryPaths, options = {}) => {
|
||||
|
||||
try {
|
||||
existingIndexCode = fs.readFileSync(indexFilePath, 'utf8');
|
||||
|
||||
/* eslint-disable no-empty */
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
fs.writeFileSync(indexFilePath, indexCode);
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
|
||||
import createIndexCode from './../src/utilities/createIndexCode';
|
||||
|
||||
import createIndexCode from '../src/utilities/createIndexCode';
|
||||
import codeExample from './codeExample';
|
||||
|
||||
describe('createIndexCode()', () => {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import path from 'path';
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
|
||||
import path from 'path';
|
||||
import glob from 'glob';
|
||||
import findIndexFiles from './../src/utilities/findIndexFiles';
|
||||
import findIndexFiles from '../src/utilities/findIndexFiles';
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, './../../fixtures/find-index-files');
|
||||
const fixturesPath = path.resolve(__dirname, '../../fixtures/find-index-files');
|
||||
|
||||
describe('findIndexFiles()', () => {
|
||||
it('finds only the directories that have an existing valid index file', () => {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import path from 'path';
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import readDirectory from '../src/utilities/readDirectory';
|
||||
|
||||
import path from 'path';
|
||||
import readDirectory from './../src/utilities/readDirectory';
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, './../../fixtures/read-directory');
|
||||
const fixturesPath = path.resolve(__dirname, '../fixtures/read-directory');
|
||||
|
||||
describe('readDirectory()', () => {
|
||||
context('target directory contains child directories', () => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import path from 'path';
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import path from 'path';
|
||||
import validateTargetDirectory from './../src/utilities/validateTargetDirectory';
|
||||
import validateTargetDirectory from '../src/utilities/validateTargetDirectory';
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, './../../fixtures/validate-target-directory');
|
||||
const fixturesPath = path.resolve(__dirname, '../fixtures/validate-target-directory');
|
||||
|
||||
describe('validateTargetDirectory()', () => {
|
||||
describe('directory path', () => {
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import writeIndex from '../src/utilities/writeIndex';
|
||||
import codeExample from './codeExample';
|
||||
import writeIndex from './../src/utilities/writeIndex';
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, './../../fixtures/write-index');
|
||||
const fixturesPath = path.resolve(__dirname, '../fixtures/write-index');
|
||||
|
||||
describe('writeIndex()', () => {
|
||||
it('creates index in target directory', () => {
|
||||
@@ -16,11 +16,11 @@ describe('writeIndex()', () => {
|
||||
|
||||
try {
|
||||
fs.unlinkSync(indexFilePath);
|
||||
/* eslint-disable no-empty */
|
||||
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
writeIndex([path.resolve(fixturesPath, './mixed')]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user