parent
da2c670d8d
commit
17c7539138
3 changed files with 34 additions and 2 deletions
|
@ -96,11 +96,17 @@ const defaultIgnore = [
|
|||
'**/.DS_Store'
|
||||
];
|
||||
|
||||
function collectFiles(cwd: string): Promise<string[]> {
|
||||
function devDependenciesIgnore(manifest: Manifest): string[] {
|
||||
const devDependencies = Object.keys(manifest.devDependencies || {});
|
||||
return devDependencies.map(d => `node_modules/${ d }/**`);
|
||||
}
|
||||
|
||||
function collectFiles(cwd: string, manifest: Manifest): Promise<string[]> {
|
||||
return nfcall<string[]>(glob, '**', { cwd, nodir: true, dot: true }).then(files => {
|
||||
return nfcall<string>(fs.readFile, path.join(cwd, '.vscodeignore'), 'utf8')
|
||||
.catch<string>(err => err.code !== 'ENOENT' ? reject(err) : resolve(''))
|
||||
.then(rawIgnore => rawIgnore.split(/[\n\r]/).map(s => s.trim()).filter(s => !!s))
|
||||
.then(ignore => devDependenciesIgnore(manifest).concat(ignore))
|
||||
.then(ignore => defaultIgnore.concat(ignore))
|
||||
.then(ignore => ignore.filter(i => !/^\s*#/.test(i)))
|
||||
.then(ignore => _.partition(ignore, i => !/^\s*!/.test(i)))
|
||||
|
@ -109,7 +115,7 @@ function collectFiles(cwd: string): Promise<string[]> {
|
|||
}
|
||||
|
||||
export function collect(cwd: string, manifest: Manifest): Promise<IFile[]> {
|
||||
return all<any>([toVsixManifest(manifest), collectFiles(cwd)])
|
||||
return all<any>([toVsixManifest(manifest), collectFiles(cwd, manifest)])
|
||||
.spread((vsixManifest: string, files: string[]) => [
|
||||
{ path: 'extension.vsixmanifest', contents: new Buffer(vsixManifest, 'utf8') },
|
||||
{ path: '[Content_Types].xml', localPath: path.join(resourcesPath, '[Content_Types].xml') },
|
||||
|
|
12
test/fixtures/devDependencies/package.json
vendored
Normal file
12
test/fixtures/devDependencies/package.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "uuid",
|
||||
"publisher": "joaomoreno",
|
||||
"version": "1.0.0",
|
||||
"engines": { "vscode": "*" },
|
||||
"dependencies": {
|
||||
"real": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fake": "*"
|
||||
}
|
||||
}
|
|
@ -38,4 +38,18 @@ describe('collect', () => {
|
|||
})
|
||||
.catch(cb);
|
||||
});
|
||||
|
||||
it('should ignore devDependencies', cb => {
|
||||
const cwd = fixture('devDependencies');
|
||||
|
||||
readManifest(cwd)
|
||||
.then(manifest => collect(cwd, manifest))
|
||||
.then(files => {
|
||||
assert.equal(files.length, 4);
|
||||
assert.ok(files.some(f => /real\/dependency\.js/.test(f.path)));
|
||||
assert.ok(!files.some(f => /fake\/dependency\.js/.test(f.path)));
|
||||
cb();
|
||||
})
|
||||
.catch(cb);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue