Skip to content

api createVSIX will cause the process to exit if printAndValidatePackagedFiles fails #1220

@kevinramharak

Description

@kevinramharak

I'm using the node API as in the following example:

/**
 * A custom `vsce package` script, to support patching `package.json` manifest
 * @param {string[]} args
 * @returns {Promise<number>}
 */
async function main(...args) {
    contents = await readFile(packageJsonPath, { encoding: 'utf-8' });
    try {
        await ensureServerWasmFilesAreCopied();
        await ensureServerModuleIsCopied();
        await patchPackageJson(contents);
        // package extension
        await createVSIX({
            packagePath: path.join(packagePath, 'out'),
        });
    } catch (error) {
        console.error(error);
        return 1;
    } finally {
        // restore original contents
        if (contents) {
            await writeFile(packageJsonPath, contents);
        }
    }
    return 0;
}

But because it follows the following code path:

The process will straight up exit, causing my finally block to never be executed. This is odd behaviour and I would suggest a change is made to throw an error to check if running from the cli or the api, and catching it higher up to see if the process should exit or rethrow.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions