5 Commits
Author SHA1 Message Date
RaidokandGajus Kuizinas 893d9931d4 fix: correct a copy-paste error in a log message (#29) 2017-01-24 11:56:57 +00:00
laggingreflexandGajus Kuizinas 9113572a43 chore: add cross-env to scripts for cross platform support (#23) 2016-12-08 06:41:03 +00:00
Gajus Kuizinas cedb893e7c 1.1.0 2016-11-30 15:48:22 +00:00
laggingreflexandGajus Kuizinas 2bafc5bb85 chore: fix typo (#25) 2016-11-30 15:47:42 +00:00
laggingreflexandGajus Kuizinas 5839536cf0 fix: update stopped working with banner (#22)
With the addition of `--banner` option index files no longer start with '// @create-index'

This new regex looks for '// @create-index' that are either at the beginning of the file (old behavior) or if it is followed by a newline.
Basically it just checks whether it exists in a file or not.

Added a test for it now.

# Conflicts:
#	src/utilities/validateTargetDirectory.js
2016-11-30 13:20:50 +00:00
4 changed files with 15 additions and 6 deletions
+5 -4
View File
@@ -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"
} }
+2 -2
View File
@@ -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
+5
View File
@@ -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(() => {