expose API: listFiles

This commit is contained in:
Joao Moreno 2017-06-21 08:57:47 +02:00
parent d8d67da92d
commit 76032e0042
2 changed files with 29 additions and 3 deletions

View file

@ -1,5 +1,5 @@
import { publish as _publish } from './publish'; import { publish as _publish } from './publish';
import { packageCommand } from './package'; import { packageCommand, listFiles as _listFiles } from './package';
export interface ICreateVSIXOptions { export interface ICreateVSIXOptions {
/** /**
@ -54,6 +54,14 @@ export interface IPublishOptions {
baseImagesUrl?: string; baseImagesUrl?: string;
} }
export interface IListFilesOptions {
/**
* The working directory of the extension. Defaults to `process.cwd()`.
*/
cwd?: string;
}
export interface IPublishVSIXOptions { export interface IPublishVSIXOptions {
/** /**
@ -77,7 +85,7 @@ export interface IPublishVSIXOptions {
/** /**
* Creates a VSIX from the extension in the current working directory. * Creates a VSIX from the extension in the current working directory.
*/ */
export function createVSIX(options?: ICreateVSIXOptions): Promise<any> { export function createVSIX(options: ICreateVSIXOptions = {}): Promise<any> {
return packageCommand(options); return packageCommand(options);
} }
@ -88,6 +96,13 @@ export function publish(options: IPublishOptions = {}): Promise<any> {
return _publish(options); return _publish(options);
} }
/**
* Lists the files included in the extension's package.
*/
export function listFiles(options: IListFilesOptions = {}): Promise<string[]> {
return _listFiles(options.cwd);
}
/** /**
* Publishes a pre-build VSIX. * Publishes a pre-build VSIX.
*/ */

View file

@ -649,7 +649,18 @@ export function packageCommand(options: IPackageOptions = {}): Promise<any> {
.then(({ packagePath }) => console.log(`Created: ${packagePath}`)); .then(({ packagePath }) => console.log(`Created: ${packagePath}`));
} }
export function ls(cwd = process.cwd()): Promise<any> { /**
* Lists the files included in the extension's package. Does not run prepublish.
*/
export function listFiles(cwd = process.cwd()): Promise<string[]> {
return readManifest(cwd)
.then(manifest => collectFiles(cwd));
}
/**
* Lists the files included in the extension's package. Runs prepublish.
*/
export function ls(cwd = process.cwd()): Promise<void> {
return readManifest(cwd) return readManifest(cwd)
.then(manifest => prepublish(cwd, manifest)) .then(manifest => prepublish(cwd, manifest))
.then(manifest => collectFiles(cwd)) .then(manifest => collectFiles(cwd))