Skip to content

Commit

Permalink
docs: add writeFile example (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleTryon committed Nov 2, 2022
1 parent 891c8d5 commit 8450296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -104,6 +104,9 @@ myWorkflow.addJob(nodeTestJob);

// The `stringify()` function on `CircleCI.Config` will return the CircleCI YAML equivalent.
const MyYamlConfig = myConfig.stringify();

// Save the config to a file in Node.js or the browser. Note, use in the browser requires user interaction.
myConfig.writeFile('config.yml');
```

`MyYamlConfig` will hold the following string (A valid CircleCI Config).
Expand Down
12 changes: 1 addition & 11 deletions sample/01-dynamic-workflow-javascript/.circleci/dynamic/index.js
@@ -1,5 +1,4 @@
const CircleCI = require("@circleci/circleci-config-sdk");
const fs = require('fs');

// Import Config Components
const jobA = require("./jobs/jobA");
Expand Down Expand Up @@ -27,14 +26,5 @@ if (1 == 1) {
// Add the dynamic workflow to the config
myConfig.addWorkflow(dynamicWorkflow);

// New Config file
const MyNewConfigYAML = myConfig.stringify();

// Write the config to file
fs.writeFile('./dynamicConfig.yml', MyNewConfigYAML, (err) => {
if (err) {
console.error(err);
return
}
})

myConfig.writeFile('config.yml');

0 comments on commit 8450296

Please sign in to comment.