Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
893d9931d4 | ||
|
|
9113572a43 | ||
|
|
cedb893e7c | ||
|
|
2bafc5bb85 | ||
|
|
5839536cf0 |
+5
-4
@@ -21,6 +21,7 @@
|
|||||||
"babel-plugin-transform-export-extensions": "^6.8.0",
|
"babel-plugin-transform-export-extensions": "^6.8.0",
|
||||||
"babel-register": "^6.18.0",
|
"babel-register": "^6.18.0",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
|
"cross-env": "^3.1.3",
|
||||||
"eslint": "^3.9.1",
|
"eslint": "^3.9.1",
|
||||||
"eslint-config-canonical": "^4.0.0",
|
"eslint-config-canonical": "^4.0.0",
|
||||||
"husky": "^0.11.9",
|
"husky": "^0.11.9",
|
||||||
@@ -43,11 +44,11 @@
|
|||||||
"url": "https://github.com/gajus/create-index"
|
"url": "https://github.com/gajus/create-index"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production babel --source-maps --copy-files ./src --out-dir ./dist",
|
"build": "cross-env NODE_ENV=production babel --source-maps --copy-files ./src --out-dir ./dist",
|
||||||
"create-index": "node ./dist/bin/create-index ./src/utilities",
|
"create-index": "node ./dist/bin/create-index ./src/utilities",
|
||||||
"lint": "NODE_ENV=development eslint ./src ./tests",
|
"lint": "cross-env NODE_ENV=development eslint ./src ./tests",
|
||||||
"precommit": "npm run test",
|
"precommit": "npm run test",
|
||||||
"test": "npm run build && npm run lint && NODE_ENV=development mocha --compilers js:babel-register"
|
"test": "npm run build && npm run lint && cross-env NODE_ENV=development mocha --compilers js:babel-register"
|
||||||
},
|
},
|
||||||
"version": "1.0.0"
|
"version": "1.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default (directoryPaths, options = {}) => {
|
|||||||
if (options.updateIndex) {
|
if (options.updateIndex) {
|
||||||
log('Update index:', options.updateIndex ? chalk.green('true') : chalk.red('false'));
|
log('Update index:', options.updateIndex ? chalk.green('true') : chalk.red('false'));
|
||||||
} else {
|
} else {
|
||||||
log('Recursive:', options.ignoreUnsafe ? chalk.green('true') : chalk.red('false'));
|
log('Recursive:', options.recursive ? chalk.green('true') : chalk.red('false'));
|
||||||
log('Ignore unsafe:', options.ignoreUnsafe ? chalk.green('true') : chalk.red('false'));
|
log('Ignore unsafe:', options.ignoreUnsafe ? chalk.green('true') : chalk.red('false'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ export default (directoryPaths, options = {}) => {
|
|||||||
fs.writeFileSync(indexFilePath, indexCode);
|
fs.writeFileSync(indexFilePath, indexCode);
|
||||||
|
|
||||||
if (existingIndexCode && existingIndexCode === indexCode) {
|
if (existingIndexCode && existingIndexCode === indexCode) {
|
||||||
log(indexFilePath, chalk.yellow('[index have not changed]'));
|
log(indexFilePath, chalk.yellow('[index has not changed]'));
|
||||||
} else if (existingIndexCode && existingIndexCode !== indexCode) {
|
} else if (existingIndexCode && existingIndexCode !== indexCode) {
|
||||||
log(indexFilePath, chalk.green('[updated index]'));
|
log(indexFilePath, chalk.green('[updated index]'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
// @create-index
|
||||||
@@ -36,6 +36,11 @@ describe('validateTargetDirectory()', () => {
|
|||||||
expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index'))).to.equal(true);
|
expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index'))).to.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
context('safe with banner', () => {
|
||||||
|
it('returns true', () => {
|
||||||
|
expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index-with-banner'))).to.equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
context('unsafe', () => {
|
context('unsafe', () => {
|
||||||
it('throws an error', () => {
|
it('throws an error', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user