Skip to content

Conversation

@JimiC
Copy link
Contributor

@JimiC JimiC commented Jul 3, 2018

Fixes #265

This PR attempts to keep backward compatibility and be compliant with Git ignoring pattern format (.gitignore)

Test fixtures and case have been included.

Note: fs.lstat has been used instead of fs.exists (line 708), in order to be compliant with deprecation of fs.exists in node@10.x. fs.existsSync was not used deliberately, in order to avoid I/O blocking.

@joaomoreno joaomoreno self-assigned this Jul 4, 2018
@joaomoreno joaomoreno added this to the Backlog milestone Jul 4, 2018
@JimiC
Copy link
Contributor Author

JimiC commented Jul 23, 2018

@joaomoreno Is there something blocking the merging?

@joaomoreno joaomoreno modified the milestones: Backlog, July 2018 Aug 2, 2018
const resources = gulp.src('src/**')
.pipe(filter(['**', '!**/*.ts']));
const resources = gulp.src('src/**', { dot: true })
.pipe(filter(['**', '!**/*.ts'], { dot: true }));
Copy link
Member

Choose a reason for hiding this comment

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

Does this actually change anything?

Copy link
Contributor Author

@JimiC JimiC Aug 2, 2018

Choose a reason for hiding this comment

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

This is crucial, otherwise minimatch does not match dotted files and folders, resulting in .vscodeignore file and .vscode folder not getting included in the compiled output, thus the relative test fails.

gulpfile.js Outdated

function watch(task) {
return cb => gulp.watch(['src/**', 'typings/**'], [task]);
return () => gulp.watch(['src/**', 'typings/**'], [task]);
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong since gulp checks for the args length of the function. If there is no parameter in the function, gulp expects a stream. If it doesn't return a stream, it marks the task as immediately completed. I suggest to leave the cb there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have abandoned gulp years ago, so I have to admit that I don't remember how it works. Since it's crucial I'll revert this.

// pattern of file name
if (!fs.existsSync(path.join(cwd, 'logger.log'))) {
fs.writeFileSync(path.join(cwd, 'logger.log'), 'log');
}
Copy link
Member

Choose a reason for hiding this comment

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

We should create a fixture instead of generating it dynamically here, it would be easier to grasp and maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original thought but I tried to keep the coding pattern. Will switch to fixture files.

.then(stat => stat && stat.isDirectory() ? `${i}/**` : i);
});
return Promise.all(promises).then<string[]>(i => Promise.resolve(i));
})
Copy link
Member

Choose a reason for hiding this comment

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

Is there really not a better way to do this without disk access?

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 can't think of another way to determine if an entry is a directory or a file. Suggestions are welcome.

@joaomoreno
Copy link
Member

@joaomoreno Is there something blocking the merging?

Only my vacation 😎

@joaomoreno joaomoreno merged commit 4cc3e83 into microsoft:master Aug 3, 2018
@joaomoreno
Copy link
Member

Thanks! 🎆

I removed the lstat usage by simply detecting whether a pattern is possibly a folder and then appending ${folder}/** to the ignore list. That should work for most cases. We let glob do all the FS work.

@JimiC JimiC deleted the fix-pattern-matching branch August 3, 2018 14:13
@JimiC
Copy link
Contributor Author

JimiC commented Aug 3, 2018

🙄 Interesting approach. Since it works, fine by me.

@jedwards1211
Copy link
Contributor

I guess no one was aware of the ignore npm package?

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.

.vscodeignore fails to exclude folders when they do not have a slash at the end

3 participants