diff --git a/README.md b/README.md index 1da188e4..81252a1b 100644 --- a/README.md +++ b/README.md @@ -1041,7 +1041,7 @@ class CustomSupplier implements SubjectTokenSupplier { } const clientOptions = { - audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience. + audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience. subject_token_type: 'urn:ietf:params:oauth:token-type:id_token', // Set the subject token type. subject_token_supplier: new CustomSupplier() // Set the custom supplier. } @@ -1049,11 +1049,11 @@ const clientOptions = { const client = new CustomSupplier(clientOptions); ``` -Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID` +Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID` Where the following variables need to be substituted: -* `WORKFORCE_POOL_ID`: The worforce pool ID. +* `$WORKFORCE_POOL_ID`: The worforce pool ID. * `$PROVIDER_ID`: The provider ID. and the workforce pool user project is the project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project). diff --git a/package.json b/package.json index 2bc32c04..c61ef089 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "chai": "^4.2.0", "cheerio": "1.0.0-rc.12", "codecov": "^3.0.2", - "execa": "^5.0.0", "gts": "^5.0.0", "is-docker": "^2.0.0", "jsdoc": "^4.0.0", diff --git a/system-test/test.kitchen.ts b/system-test/test.kitchen.ts index e818ef26..1d10eed9 100644 --- a/system-test/test.kitchen.ts +++ b/system-test/test.kitchen.ts @@ -14,13 +14,13 @@ import * as assert from 'assert'; import {describe, it, afterEach} from 'mocha'; -import * as execa from 'execa'; import * as fs from 'fs'; import * as mv from 'mv'; import {ncp} from 'ncp'; import * as os from 'os'; import * as path from 'path'; import {promisify} from 'util'; +import {spawn} from 'child_process'; const mvp = promisify(mv) as {} as (...args: string[]) => Promise; const ncpp = promisify(ncp); @@ -29,18 +29,39 @@ const keep = !!process.env.GALN_KEEP_TEMPDIRS; const pkg = require('../../package.json'); let stagingDir: string; + +/** + * Spawns and runs a command asynchronously. + * + * @param params params to pass to {@link spawn} + */ +async function run(...params: Parameters) { + const command = spawn(...params); + + await new Promise((resolve, reject) => { + // Unlike `exec`/`execFile`, this keeps the order of STDOUT/STDERR in case they were interweaved; + // making it easier to debug and follow along. + command.stdout?.on('data', console.log); + command.stderr?.on('data', console.error); + command.on('close', (code, signal) => { + return code === 0 ? resolve() : reject({code, signal}); + }); + command.on('error', reject); + }); +} + async function packAndInstall() { stagingDir = await fs.promises.mkdtemp( path.join(os.tmpdir(), 'google-auth-library-nodejs-pack-') ); - await execa('npm', ['pack'], {stdio: 'inherit'}); + await run('npm', ['pack'], {}); const tarball = `${pkg.name}-${pkg.version}.tgz`; // stagingPath can be on another filesystem so fs.rename() will fail // with EXDEV, hence we use `mv` module here. await mvp(tarball, `${stagingDir}/google-auth-library.tgz`); await ncpp('system-test/fixtures/kitchen', `${stagingDir}/`); - await execa('npm', ['install'], {cwd: `${stagingDir}/`, stdio: 'inherit'}); + await run('npm', ['install'], {cwd: `${stagingDir}/`}); } describe('pack and install', () => { @@ -61,10 +82,10 @@ describe('pack and install', () => { this.timeout(40000); await packAndInstall(); // we expect npm install is executed in the before hook - await execa('npx', ['webpack'], {cwd: `${stagingDir}/`, stdio: 'inherit'}); + await run('npx', ['webpack'], {cwd: `${stagingDir}/`}); const bundle = path.join(stagingDir, 'dist', 'bundle.min.js'); // ensure it is a non-empty bundle - assert(fs.statSync(bundle).size); + assert(fs.statSync(bundle).size, 'Size should not be empty'); }); /**