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