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: ignore files with .liveserverignore #130

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

rjoydip-zz
Copy link
Collaborator

@rjoydip-zz rjoydip-zz commented May 20, 2018

  • New Feature: Yes
  • Fix typo: Yes

Description
Ignore file through .liveserverignore the file just like we do like .gitignore. Only need to create a .liveserverignore file in project root level.

Fixed issue

  • Typo regarding ignore file in live server. The ignore property wasn't in live server param.
  • Fixed tslint shadow name error in appModel > openBrowser function.

return Array.isArray(val) ? val : [val];
}

private unique(_arr: Array<any>): Array<any> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is array unique fn is immutable. slice will create problem and more expensive(for mutability).

@@ -397,14 404,19 @@ LiveServer.start = function (options, callback) {
function (testPath) { // Always ignore dotfiles (important e.g. because editor hidden temp files)
return testPath !== "." && /(^[.#]|(?:__|~)$)/.test(path.basename(testPath));
},
"**/node_modules/**"
"node_modules/",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

node_modules/ any folder under node modules can be ignored. Just like we all do in .gitignore.

src/appModel.ts Outdated
if (patterns.length) {
params.ignore = patterns;
} else {
params.ignore = Config.getIgnoreFiles;
Copy link
Collaborator Author

@rjoydip-zz rjoydip-zz May 20, 2018

Choose a reason for hiding this comment

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

Previously Config.getIgnoreFiles wasn't attach on params

Copy link
Owner

Choose a reason for hiding this comment

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

Actually not.. it is attached in Helper.ts. I agree, my code is not clean at that time. I've to refactor the code.

https://github.com/ritwickdey/vscode-live-server/blob/master/src/Helper.ts#L82

src/extension.ts Outdated
@@ -38,5 38,6 @@ export function activate(context: ExtensionContext) {


export function deactivate() {

const appModel = new AppModel();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Live server shutdown when editor deactivate.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay! Sorry for late (you know I've exam - and now finished)

anyway, just create new AppModel(); object from out the function (like a global object of the file), so that both activate & deactivate function can share the same instance of the AppModel. I think it'll be better. Is not it?

@rjoydip-zz
Copy link
Collaborator Author

Yes that's will be better. Np I will do that

@ritwickdey
Copy link
Owner

Can you please able to complete this in the weekend?

@rjoydip-zz
Copy link
Collaborator Author

I have fixed the requesed changes. Have you reviewed that?

@ritwickdey
Copy link
Owner

Ok, I'm testing on my local machine.

@ritwickdey
Copy link
Owner

Sorry, it's not working in my machine, even reload is working on changes in the node_module (which is blacklisted by default) 😿

@rjoydip-zz
Copy link
Collaborator Author

Then I have to check it again

@rjoydip-zz
Copy link
Collaborator Author

rjoydip-zz commented Jun 16, 2018

@ritwickdey Can you tell me how you testing. It's working on here. Check again I made some changes.

@ritwickdey
Copy link
Owner

SOrry for late.

This is my settings

image


if (patterns.length) {
params.ignore = patterns;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Can you please move this code here

const ignorePathGlob = Config.getIgnoreFiles || [];
const ignoreFiles = [];
ignorePathGlob.forEach(ignoredPath => {
if (!ignoredPath.startsWith('/') || !ignoredPath.startsWith('\\'))
ignoreFiles.push(workspacePath path.sep ignoredPath);

const ignorePathGlob = patterns || Config.getIgnoreFiles || [];

if (options.ignore) {
ignored = ignored.concat(options.ignore);
ignored.push('**/node_modules/**/*');
Copy link
Owner

Choose a reason for hiding this comment

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

It should be **/node_modules/**. I think this is why live server responding on changes into node_module folder

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NP because **/node_modules/** is equivalent with **/node_modules/**/*

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.

3 participants