curved-pharmacist-41509
03/10/2021, 3:21 AMup
doesn’t run code which is checking for isDryMode()
white-balloon-205
03/10/2021, 3:32 AMcurved-pharmacist-41509
03/10/2021, 3:58 AMimport * as pulumi from '@pulumi/pulumi'
import { runCommandThatMustSucceed } from './run-command'
export interface BuildStepArgs {
/**
* The command to run
*/
command: pulumi.Input<string>
/**
* The command arguments
*/
args: pulumi.Input<string[]>
/**
* The cwd of the command
*/
cwd?: pulumi.Input<string>
/**
* The env of the command
*/
env?: {
[key: string]: pulumi.Input<string>
}
}
export class BuildStep extends pulumi.ComponentResource {
public buildStdOut: pulumi.Output<string>
public done: pulumi.Output<boolean>
constructor(
name: string,
args: BuildStepArgs,
opts?: pulumi.ComponentResourceOptions,
) {
super('build-step', name, {}, opts)
const buildStdOut = pulumi.output(args).apply(async (buildArgs) => {
if (
(pulumi.runtime.isDryRun() &&
!pulumi.runtime.isTestModeEnabled())
) {
const stdOut = await runCommandThatMustSucceed({
cmd: buildArgs.command,
args: buildArgs.args,
cwd: buildArgs.cwd,
logResource: this,
reportFullCommandLine: true,
env: buildArgs.env,
})
return stdOut
}
return 'Build run during preview'
})
this.buildStdOut = buildStdOut
this.done = buildStdOut.apply(() => true)
this.registerOutputs({
buildStdOut: this.buildStdOut,
done: this.done,
})
}
}
This is a resource inspired by your docker build, just a bit more generic.up
a stack. It works on subsequent `up`s