sparse-intern-71089
03/11/2021, 1:29 AMlittle-cartoon-10569
03/11/2021, 2:01 AMapply() blocks, and that's a bit tricky to synchonize properly.little-cartoon-10569
03/11/2021, 2:02 AMval.apply((contents) => console.log(contents));stocky-france-59380
03/11/2021, 2:11 AMlittle-cartoon-10569
03/11/2021, 2:13 AMlittle-cartoon-10569
03/11/2021, 2:17 AMlittle-cartoon-10569
03/11/2021, 2:18 AMapply() blocks.little-cartoon-10569
03/11/2021, 2:18 AMlittle-cartoon-10569
03/11/2021, 2:19 AMstocky-france-59380
03/11/2021, 2:23 AMlittle-cartoon-10569
03/11/2021, 2:25 AMstocky-france-59380
03/11/2021, 2:33 AM>
const yaml = require('js-yaml');
const fs = require('fs');
describe('js-yaml', function () {
  it('read', function (done) {
    let fileContent = fs.readFileSync('./foo.yml', 'utf-8');
    let data = yaml.load(fileContent);
    console.log(data);
    done();
  });
});stocky-france-59380
03/11/2021, 2:36 AMdescribe('yaml', function () {
    it('reads', function (done) {
      pulumi.all([infra.ymml.urn, infra.ymml]).apply(([urn, thefile]) => {
        console.log(urn);
        var val = thefile.getResource('v1/Service', 'my-service');
        val.apply((content) => console.log(content.apiVersion));
        done();
      });
    });
  });
});
where foo.yaml looks like this
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
the output is
yaml
urn:pulumi:stack::project::kubernetes:yaml:ConfigFile::yamlfile
      ✓ reads
(node:72056) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:72056) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 4)little-cartoon-10569
03/11/2021, 2:45 AMlittle-cartoon-10569
03/11/2021, 2:46 AMlittle-cartoon-10569
03/11/2021, 2:48 AMasync to the function you pass to itlittle-cartoon-10569
03/11/2021, 2:48 AM