diff --git a/resources/extension.vsixmanifest b/resources/extension.vsixmanifest
index 891b247..d259907 100644
--- a/resources/extension.vsixmanifest
+++ b/resources/extension.vsixmanifest
@@ -12,6 +12,7 @@
-
+
+ <% _.forEach(assets, function (asset) { %><% }); %>
diff --git a/src/package.ts b/src/package.ts
index 12e97f5..35a8686 100644
--- a/src/package.ts
+++ b/src/package.ts
@@ -27,6 +27,11 @@ export interface IPackageResult {
packagePath: string;
}
+export interface IAsset {
+ type: string;
+ path: string;
+}
+
function validateManifest(manifest: Manifest): Promise {
if (!manifest.publisher) {
return Promise.reject('Manifest missing field: publisher');
@@ -82,7 +87,15 @@ function prepublish(cwd: string, manifest: Manifest): Promise {
.catch(err => Promise.reject(err.message));
}
-export function toVsixManifest(manifest: Manifest): Promise {
+export function toVsixManifest(manifest: Manifest, files: IFile[]): Promise {
+ const assets = files.map(f => {
+ if (/^extension\/README.md$/i.test(f.path)) {
+ return { type: 'Microsoft.VisualStudio.Services.Content.Details', path: f.path };
+ }
+
+ return null;
+ }).filter(f => !!f);
+
return readFile(vsixManifestTemplatePath, 'utf8')
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
.then(vsixManifestTemplate => vsixManifestTemplate({
@@ -92,7 +105,7 @@ export function toVsixManifest(manifest: Manifest): Promise {
publisher: manifest.publisher,
description: manifest.description || '',
tags: (manifest.keywords || []).concat('vscode').join(';'),
- assets: []
+ assets
}));
}
@@ -122,13 +135,17 @@ function collectFiles(cwd: string, manifest: Manifest): Promise {
}
export function collect(cwd: string, manifest: Manifest): Promise {
- return Promise.all([toVsixManifest(manifest), collectFiles(cwd, manifest)])
- .then<{ vsixManifest: string; files: string[]; }>(promises => _.indexBy(promises, (o,i) => i ? 'files' : 'vsixManifest'))
- .then(({ vsixManifest, files }) => [
- { path: 'extension.vsixmanifest', contents: new Buffer(vsixManifest, 'utf8') },
- { path: '[Content_Types].xml', localPath: path.join(resourcesPath, '[Content_Types].xml') },
- ...files.map(f => ({ path: `extension/${ f }`, localPath: path.join(cwd, f) }))
- ]);
+ return collectFiles(cwd, manifest).then(fileNames => {
+ const files = fileNames.map(f => ({ path: `extension/${ f }`, localPath: path.join(cwd, f) }));
+
+ return toVsixManifest(manifest, files).then(vsixManifest => {
+ return [
+ { path: 'extension.vsixmanifest', contents: new Buffer(vsixManifest, 'utf8') },
+ { path: '[Content_Types].xml', localPath: path.join(resourcesPath, '[Content_Types].xml') },
+ ...files
+ ];
+ });
+ });
}
function writeVsix(files: IFile[], packagePath: string): Promise {
diff --git a/test/package.test.js b/test/package.test.js
index 81f57c8..abe291d 100644
--- a/test/package.test.js
+++ b/test/package.test.js
@@ -69,7 +69,7 @@ describe('toVsixManifest', () => {
description: 'test extension'
};
- return toVsixManifest(manifest)
+ return toVsixManifest(manifest, [])
.then(xml => parseXml(xml))
.then(result => {
assert.ok(result);
@@ -97,4 +97,25 @@ describe('toVsixManifest', () => {
assert.equal(result.PackageManifest.Assets[0].Asset[0].$.Path, 'extension/package.json');
});
});
+
+ it('should treat README.md as asset', () => {
+ const manifest = {
+ name: 'test',
+ publisher: 'mocha',
+ version: '0.0.1',
+ description: 'test extension'
+ };
+
+ const files = [
+ { path: 'extension/readme.md' }
+ ];
+
+ return toVsixManifest(manifest, files)
+ .then(xml => parseXml(xml))
+ .then(result => {
+ assert.equal(result.PackageManifest.Assets[0].Asset.length, 2);
+ assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Type, 'Microsoft.VisualStudio.Services.Content.Details');
+ assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/readme.md');
+ });
+ });
});
\ No newline at end of file