-
Notifications
You must be signed in to change notification settings - Fork 438
Expand file tree
/
Copy pathpackage.ts
More file actions
57 lines (48 loc) · 1.76 KB
/
Copy pathpackage.ts
File metadata and controls
57 lines (48 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Argv } from 'yargs';
import { getCLIHost } from '../../spec-common/cliHost';
import { loadNativeModule } from '../../spec-common/commonUtils';
import { mapLogLevel } from '../../spec-utils/log';
import { getPackageConfig } from '../../spec-utils/product';
import { createLog } from '../devContainers';
import { UnpackArgv } from '../devContainersSpecCLI';
import { doFeaturesPackageCommand } from './packageCommandImpl';
import { PackageCommandInput, PackageOptions } from '../collectionCommonUtils/package';
import { runAsyncHandler } from '../utils';
export function featuresPackageOptions(y: Argv) {
return PackageOptions(y, 'feature');
}
export type FeaturesPackageArgs = UnpackArgv<ReturnType<typeof featuresPackageOptions>>;
export function featuresPackageHandler(args: FeaturesPackageArgs) {
runAsyncHandler(featuresPackage.bind(null, args));
}
async function featuresPackage({
'target': targetFolder,
'log-level': inputLogLevel,
'output-folder': outputDir,
'force-clean-output-folder': forceCleanOutputDir,
}: FeaturesPackageArgs) {
const disposables: (() => Promise<unknown> | undefined)[] = [];
const dispose = async () => {
await Promise.all(disposables.map(d => d()));
};
const pkg = getPackageConfig();
const cwd = process.cwd();
const cliHost = await getCLIHost(cwd, loadNativeModule, true);
const output = createLog({
logLevel: mapLogLevel(inputLogLevel),
logFormat: 'text',
log: (str) => process.stderr.write(str),
terminalDimensions: undefined,
}, pkg, new Date(), disposables);
const args: PackageCommandInput = {
cliHost,
targetFolder,
outputDir,
output,
disposables,
forceCleanOutputDir: forceCleanOutputDir
};
const exitCode = !!(await doFeaturesPackageCommand(args)) ? 0 : 1;
await dispose();
process.exit(exitCode);
}