Skip to content

Commit 2e76a86

Browse files
committed
fix: use ignore npm package instead of half-baked custom code for .vscodeignore
1 parent 2ca36aa commit 2e76a86

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

Diff for: package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
"denodeify": "^1.2.1",
4343
"didyoumean": "^1.2.1",
4444
"glob": "^7.0.6",
45+
"ignore": "^5.1.4",
4546
"lodash": "^4.17.10",
4647
"markdown-it": "^8.3.1",
4748
"mime": "^1.3.4",
48-
"minimatch": "^3.0.3",
4949
"osenv": "^0.1.3",
5050
"parse-semver": "^1.1.1",
5151
"read": "^1.0.7",
@@ -64,7 +64,6 @@
6464
"@types/lodash": "^4.14.123",
6565
"@types/markdown-it": "0.0.2",
6666
"@types/mime": "^1",
67-
"@types/minimatch": "^3.0.3",
6867
"@types/mocha": "^5.2.6",
6968
"@types/node": "^8",
7069
"@types/read": "^0.0.28",

Diff for: src/package.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Manifest } from './manifest';
77
import { ITranslations, patchNLS } from './nls';
88
import * as util from './util';
99
import * as _glob from 'glob';
10-
import * as minimatch from 'minimatch';
1110
import * as denodeify from 'denodeify';
1211
import * as markdownit from 'markdown-it';
1312
import * as cheerio from 'cheerio';
@@ -16,6 +15,7 @@ import { lookup } from 'mime';
1615
import * as urljoin from 'url-join';
1716
import { validatePublisher, validateExtensionName, validateVersion, validateEngineCompatibility, validateVSCodeTypesCompatibility } from './validation';
1817
import { getDependencies } from './npm';
18+
import ignore from 'ignore'
1919

2020
const readFile = denodeify<string, string, string>(fs.readFile);
2121
const unlink = denodeify<string, void>(fs.unlink as any);
@@ -27,8 +27,6 @@ const resourcesPath = path.join(path.dirname(__dirname), 'resources');
2727
const vsixManifestTemplatePath = path.join(resourcesPath, 'extension.vsixmanifest');
2828
const contentTypesTemplatePath = path.join(resourcesPath, '[Content_Types].xml');
2929

30-
const MinimatchOptions: minimatch.IOptions = { dot: true };
31-
3230
export interface IFile {
3331
path: string;
3432
contents?: Buffer | string;
@@ -834,21 +832,7 @@ function collectFiles(cwd: string, useYarn = false, dependencyEntryPoints?: stri
834832
return readFile(ignoreFile ? ignoreFile : path.join(cwd, '.vscodeignore'), 'utf8')
835833
.catch<string>(err => err.code !== 'ENOENT' ? Promise.reject(err) : ignoreFile ? Promise.reject(err) : Promise.resolve(''))
836834

837-
// Parse raw ignore by splitting output into lines and filtering out empty lines and comments
838-
.then(rawIgnore => rawIgnore.split(/[\n\r]/).map(s => s.trim()).filter(s => !!s).filter(i => !/^\s*#/.test(i)))
839-
840-
// Add '/**' to possible folder names
841-
.then(ignore => [...ignore, ...ignore.filter(i => !/(^|\/)[^/]*\*[^/]*$/.test(i)).map(i => /\/$/.test(i) ? `${i}**` : `${i}/**`)])
842-
843-
// Combine with default ignore list
844-
.then(ignore => [...defaultIgnore, ...ignore, '!package.json'])
845-
846-
// Split into ignore and negate list
847-
.then(ignore => _.partition(ignore, i => !/^\s*!/.test(i)))
848-
.then(r => ({ ignore: r[0], negate: r[1] }))
849-
850-
// Filter out files
851-
.then(({ ignore, negate }) => files.filter(f => !ignore.some(i => minimatch(f, i, MinimatchOptions)) || negate.some(i => minimatch(f, i.substr(1), MinimatchOptions))));
835+
.then(rawIgnore => ignore().add(defaultIgnore).add(rawIgnore).filter(files))
852836
});
853837
}
854838

Diff for: yarn.lock

+7-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.1.tgz#2cf42972d0931c1060c7d5fa6627fce6bd876f2f"
4747
integrity sha512-rek8twk9C58gHYqIrUlJsx8NQMhlxqHzln9Z9ODqiNgv3/s+ZwIrfr+djqzsnVM12xe9hL98iJ20lj2RvCBv6A==
4848

49-
"@types/minimatch@*", "@types/minimatch@^3.0.3":
49+
"@types/minimatch@*":
5050
version "3.0.3"
5151
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
5252
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
@@ -460,6 +460,11 @@ htmlparser2@^3.9.1:
460460
inherits "^2.0.1"
461461
readable-stream "^3.0.6"
462462

463+
ignore@^5.1.4:
464+
version "5.1.4"
465+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
466+
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==
467+
463468
inflight@^1.0.4:
464469
version "1.0.6"
465470
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
@@ -579,7 +584,7 @@ mimic-fn@^2.0.0:
579584
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
580585
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
581586

582-
[email protected], minimatch@^3.0.3, minimatch@^3.0.4:
587+
[email protected], minimatch@^3.0.4:
583588
version "3.0.4"
584589
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
585590
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==

0 commit comments

Comments
 (0)