Comments (7)
Thought it could be closed.
from node-ignore.
.gitignore
exactly works in this way.
The spec says:
It is not possible to re-include a file if a parent directory of that file is excluded.
You could sightly change your ignore rules as:
.git/*
!.git/config
.ftpconfig
I thought it is solved.
from node-ignore.
No solved my problem!
I use Windows.
My rules:
.git/*
!.git/config
.ftpconfig
Accepted:
D:/ => true
D:/DEV/ => true
D:/DEV/_incubator/ => true
D:/DEV/_incubator/cubicbox/ => true
D:/DEV/_incubator/cubicbox/.ftpconfig => false [It's OK]
D:/DEV/_incubator/cubicbox/.git/ => true
D:/DEV/_incubator/cubicbox/.git/config => true
D:/DEV/_incubator/cubicbox/.git/description => true [This and other files is bad!]
from node-ignore.
@icetee I've added a test spec of your case, and it is ok with windows. See here for test result and here for the test case.
Could you please provide any code slices or examples?
And BTW, you should not do something like this on windows:
// WRONG!
ignore().add(rules).ignores('D:/DEV/_incubator/cubicbox/.git/description')
Because .gitignore
does not works with absolute paths but only relative ones. We should use path.relative()
method first, then do:
const rootOfYourProject = 'D:/DEV/_incubator/cubicbox/'
const absoluteFilePath = 'D:/DEV/_incubator/cubicbox/.git/description'
ignore().add(rules).ignores(
// Right way
path.relative(rootOfYourProject, absoluteFilePath)
)
from node-ignore.
@kaelzhang Can you help me?
I write spec in other test file custom.spec.js
and run ./node_modules/.bin/mocha --grep deep
:
var ignore = require('../');
var expect = require('chai').expect;
var ig = null;
describe('deep', function() {
before(function() {
ig = ignore().add([
'abc',
'!abc/b',
]);
});
it('#0', function() {
expect(ig.ignores('abc')).to.equal(true); // CORRECT
});
it('#1', function() {
expect(ig.ignores('abcdefg')).to.equal(false); // CORRECT
});
it('#2', function() {
expect(ig.ignores('abc/b')).to.equal(false); // WRONG
});
});
It's as if he did not notice that he was negative. Do I do something wrong?
from node-ignore.
The gitignore spec might help you.
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
It is not possible to re-include a file if a parent directory of that file is excluded.
Let me explain that.
The parent directory of abc/b
is abc
, and abc
is ignored, so abc/b
could not re-include again by the rule !abc/b
.
The correct way:
ignore().add([
// The directory `abc` is not ignored, while only the things INSIDE `abc` are ignored.
'abc/*',
'!abc/b'
]).ignores('abc/b')
// -> false
If abc
is already ignored, we could
ignore().add([
// If already ignores
'abc',
// It could be re-included itself
'!abc',
'abc/*',
'!abc/b'
]).ignores('abc/b') // -> false
from node-ignore.
I understand! Thanks for the help!
from node-ignore.
Related Issues (20)
- Is it not possible to test .npmignore using this library? HOT 6
- Feature request: .remove method HOT 1
- Ignore rules containing .. as a path element HOT 7
- Warn about files ignoring themselves? HOT 1
- How to check if the working directory should be ignored? HOT 1
- TypeScript: add support for `readonly string[]`
- Negate broken HOT 1
- [Feature] Add export field or new package to render real world gitignore? HOT 2
- [Feature] npm exec script HOT 1
- wrong result for node_modules HOT 2
- directory ending with / not always correctly ignored HOT 5
- Find out which paths to watch HOT 4
- Negative pattern ignored when inside a subdirectory HOT 2
- Negated directory inclusion fails with glob HOT 1
- Trailing backslash in the ignore file is throwing a syntax error. HOT 1
- \# does not work HOT 1
- Pathname should be a path.relative()d pathname Error with ../ path HOT 2
- Add support for OR syntax `{js,ts}` HOT 3
- foo/* not correctly respected HOT 4
- "*.app" ignores "Notificator.app/Contents/PkgInfo" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ignore.