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

Set ignore file to .crxignore like .gitignore #49

Closed
wants to merge 2 commits into from

Conversation

pastak
Copy link

@pastak pastak commented Oct 26, 2015

It allows to build crx and zip without files written into .crxignore. It can remove useless file like npm modules, README so it makes file size as low as possible.

Syntax of .crxignore is same as .gitignore. You can write below

node_module
*.log
dir/file/to/path.js

@@ -187,6 +188,8 @@ ChromeExtension.prototype = {
throw new Error('crx.load needs to be called first in order to prepare the workspace.');
}

var crxignore = gitignoreParser.compile(fs.readFileSync(selfie.path + '/.crxignore', 'utf8'))
Copy link
Owner

Choose a reason for hiding this comment

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

What if the file does not exist?

Copy link
Author

Choose a reason for hiding this comment

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

Oh, it will be error. I'll fix it. 😢

@@ -187,6 +188,11 @@ ChromeExtension.prototype = {
throw new Error('crx.load needs to be called first in order to prepare the workspace.');
}

var crxignore = null
try {
crxignore = gitignoreParser.compile(fs.readFileSync(selfie.path + '/.crxignore', 'utf8'))
Copy link
Owner

Choose a reason for hiding this comment

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

Also, we do not want silent try catch, nor sync operations.

Best would be:

  • feeding ignore patterns from the CLI (eg: crx --ignore */*.js --ignore **/.* ... )
  • fetching the ignore rules form a .crxignore file indeed (but you want the result to be a list of ignored files) (eg: crx --ignore-file .crxignore --ignore-file another/.crxignore)

Both would be provided as a parameter to the class itself.

I reckon this PR addresses the --ignore-file only but you get the idea.

@thom4parisot
Copy link
Owner

Also, because this is a new feature, you want to provide tests to make sure the various edge cases are addressed.

And documentation in the README :-)

If you never did any of these in the past, no worries, you can ask as many questions as needed to reach a successful merge :-)

@pastak
Copy link
Author

pastak commented Oct 27, 2015

@oncletom Thank you for your friendly comments 😸

I think --ignore-file is better idea because feeding from CLI lets them to write too many patterns is hard for users.

Also, because this is a new feature, you want to provide tests to make sure the various edge cases are addressed.

Yeah, I want to documentation and provide tests.

@thom4parisot
Copy link
Owner

Cool!

Also have a look at https://github.com/jonschlinkert/glob-fs-gitignore or https://www.npmjs.com/package/gitignore-to-glob + node-glob, as they seem to do the job and we're interested in using glob-fs so as grunt-crx can proxy its ignore pattern to crx safely :-)

@pastak
Copy link
Author

pastak commented Oct 28, 2015

jonschlinkert/glob-fs-gitignore looks good!

@thom4parisot
Copy link
Owner

Hey @pastak,

although I feel ignore files or selecting them in a finer way (cf. #66) would help, I don't believe supporting an ignore file is the first step to implement it.

I'd rather have a good and solid API then add an ignore file if this is a common need. I'd rather stay close to the CLI rather than having an implicit configuration file – we already have too many of them.

I hope you don't mind me closing your proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants