Anyone using FileAsset in their plans? It seems to...
# typescript
b
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
Promises can be turned into outputs by calling
pulumi.output(promise)
. Would that help?
b
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?