https://pulumi.com logo
#typescript
Title
# typescript
b

best-summer-38252

02/01/2023, 5:31 AM
Anyone using FileAsset in their plans? It seems to be the only resource that returns a promise. I want a docker image resouce to depend on compliedApp
Copy code
const compliedApp = new pulumi.asset.FileAsset("src/app.ts").path
  .then((inPath) => {
    const name = path.parse(inPath).name;
    const outPath = path.join("dist", name, "index.mjs");
    return new local.Command(`compile${startcase(name)}`, {
      assetPaths: [outPath],
      dir: ".",
      create: `pnpm exec ncc build -m -s ${inPath} -o ${path.join("dist", name)}`,
      delete: `rm -rf ${path.dirname(outPath)}`,
    });
  })
  .then((r) => ({
    inputPath: "src/app.ts",
    outputPath: r.assetPaths[0],
  }));
l

little-cartoon-10569

02/01/2023, 6:33 AM
Promises can be turned into outputs by calling
pulumi.output(promise)
. Would that help?
b

best-summer-38252

02/14/2023, 12:56 AM
Nice, Ill try it. For now I switch over to just using Nodes API to read the file and pulumi diff'd the source input so a change in the file resulted in updating the resource. That leaves me with the question - why use the FileAsset at all?
23 Views