Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(#31): Add ignore option #37

Merged
merged 1 commit into from
Mar 13, 2017
Merged

Conversation

hinok
Copy link
Contributor

@hinok hinok commented Mar 12, 2017

  • This commit add functionality to ignore files
    based on provided regexps.

  • in index.js config must be specified as below

    // @create-index {"ignore":["/foo.js"]}

@gajus
Copy link
Owner

gajus commented Mar 13, 2017

Thank you for the PR.

This lack documentation, README.md changes.

@@ -2,8 +2,6 @@ import chalk from 'chalk';
import moment from 'moment';

export default (...append) => {
/* eslint-disable no-console */
/* eslint-disable no-console */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use // eslint-disable-next-line

@@ -0,0 +1,3 @@
const CREATE_INDEX_PATTERN = /(?:^|[\n\r]+)\/\/ @create-index\s?({.*})?[\n\r]+/;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const CREATE_INDEX_PATTERN ...

package.json Outdated
@@ -48,7 +48,8 @@
"create-index": "node ./dist/bin/create-index ./src/utilities",
"lint": "cross-env NODE_ENV=development eslint ./src ./tests",
"precommit": "npm run test",
"test": "npm run build && npm run lint && cross-env 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",
"test:watch": "cross-env NODE_ENV=development mocha --watch --reporter spec --bail --compilers js:babel-register"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove test:watch.

writeIndex([path.resolve(fixturesPath, 'mixed')]);
it('creates index with config in target directory', () => {
const indexFilePath = path.resolve(fixturesPath, 'with-config/index.js');
const ignoredExportLine = `export { default as bar } from './bar.js';`; // eslint-disable-line quotes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use // eslint-disable-next-line

};

const appendToFile = (filePath, content) => {
try {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason for swallowing an error?


const removeFileByPath = (filePath) => {
// eslint-disable-next-line no-empty
try {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason for swallowing an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to follow "code style" in the project so if you look here https://github.com/gajus/create-index/pull/37/files#diff-f546cc5537a07f2741198b32e7ef3aa9L17 the same pattern with swallowing an error has been already used. I decided to just copy and use it.

Anyway I will remove them if you want, no problem :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thats in the test/. Meh, I am indifferent.

import hasIndex from './hasIndex';
import {CREATE_INDEX_PATTERN} from './constants';

const isString = (str) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary helpers. I am all pro declarative programming, though typeof str === 'string' is already achieving the same.

};

const isEmptyString = (str) => {
return str.length === 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary helpers. I am all pro declarative programming, though str.length is already achieving the same.

@hinok hinok force-pushed the feature/add-ignore-option branch 3 times, most recently from 5e170c1 to b162c74 Compare March 13, 2017 18:14
@hinok
Copy link
Contributor Author

hinok commented Mar 13, 2017

Sorry for so many changes. I applied all requested changes and removed "swallowing errors" from tests. I added also section about ignore in README.md.

@gajus
Copy link
Owner

gajus commented Mar 13, 2017

Is this ready to be merged?

- Add functionality to ignore files based on provided
regular expressions
- Support writeIndex and writeIndexCli
- in index.js config must be specified as below

    // @create-index {"ignore":["/foo.js"]}
@hinok hinok force-pushed the feature/add-ignore-option branch from b162c74 to 2e2e7eb Compare March 13, 2017 20:23
@hinok
Copy link
Contributor Author

hinok commented Mar 13, 2017

I thought that writeIndexCli.js uses writeIndex.js, it doesn't - my fault, I didn't check it before but it's fixed already.

I also checked this PR on my local project where I use create-index heavily to maintain icons, it works 💃

Please feel free to correct any english language issues.
I think that it's ready to be merged.

@gajus gajus merged commit bf45925 into gajus:master Mar 13, 2017
@gajus
Copy link
Owner

gajus commented Mar 13, 2017

Thank you

@hinok hinok deleted the feature/add-ignore-option branch March 13, 2017 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants