Merge branch 'fix-manifest-overriding' of https://github.com/robertohuertasm/vscode-vsce into robertohuertasm-fix-manifest-overriding
This commit is contained in:
commit
08528f2251
3 changed files with 18 additions and 2 deletions
|
@ -442,7 +442,7 @@ export function validateManifest(manifest: Manifest): Manifest {
|
|||
return manifest;
|
||||
}
|
||||
|
||||
export function readManifest(cwd = process.cwd()): Promise<Manifest> {
|
||||
export function readManifest(cwd = process.cwd(), nls = true): Promise<Manifest> {
|
||||
const manifestPath = path.join(cwd, 'package.json');
|
||||
const manifestNLSPath = path.join(cwd, 'package.nls.json');
|
||||
|
||||
|
@ -457,6 +457,8 @@ export function readManifest(cwd = process.cwd()): Promise<Manifest> {
|
|||
})
|
||||
.then(validateManifest);
|
||||
|
||||
if (!nls) return manifest;
|
||||
|
||||
const manifestNLS = readFile(manifestNLSPath, 'utf8')
|
||||
.catch<string>(err => err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve('{}'))
|
||||
.then<ITranslations>(raw => {
|
||||
|
@ -470,6 +472,7 @@ export function readManifest(cwd = process.cwd()): Promise<Manifest> {
|
|||
return Promise.all([manifest, manifestNLS]).then(([manifest, translations]) => {
|
||||
return patchNLS(manifest, translations);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function writeManifest(cwd: string, manifest: Manifest): Promise<void> {
|
||||
|
|
|
@ -90,7 +90,7 @@ function versionBump(cwd: string = process.cwd(), version?: string): Promise<voi
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return readManifest(cwd)
|
||||
return readManifest(cwd, false)
|
||||
.then(manifest => {
|
||||
switch (version) {
|
||||
case 'major':
|
||||
|
|
|
@ -135,6 +135,19 @@ describe('readManifest', () => {
|
|||
assert.equal(manifest.contributes.debuggers[0].label, translations['node.label']);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not patch NLS if required', () => {
|
||||
const cwd = fixture('nls');
|
||||
const raw = require('./fixtures/nls/package.json');
|
||||
const translations = require('./fixtures/nls/package.nls.json');
|
||||
|
||||
return readManifest(cwd, false)
|
||||
.then((manifest: any) => {
|
||||
assert.equal(manifest.name, raw.name);
|
||||
assert.notEqual(manifest.description, translations['extension.description']);
|
||||
assert.notEqual(manifest.contributes.debuggers[0].label, translations['node.label']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateManifest', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue