Skip to content

Commit

Permalink
fix: fs and util.exec examples do not work on windows (#7193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr authored Oct 10, 2024
1 parent a9a35a6 commit 680d20f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
4 changes: 3 additions & 1 deletion docs/by-example/30-reading-writing-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ image: /img/wing-by-example.png
```js playground example title="main.w"
bring fs;

let filename: str = "/tmp/test.txt";
let filename: str = fs.join(@dirname, "test.txt");

log(fs.exists(filename));

Expand All @@ -29,6 +29,8 @@ fs.appendFile(filename, "testing");
let extendedValue = fs.readFile(filename);

log(extendedValue);

fs.remove(filename);
```
```bash title="Wing console output"
Expand Down
26 changes: 15 additions & 11 deletions docs/by-example/35-exec-processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ image: /img/wing-by-example.png
```js playground example title="main.w"
bring util;

let output = util.exec("echo", ["-n", "Hello, Wing!"]);
let dir = @dirname;

// exec with custom environment variables
let output2 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo $WING_TARGET $ENV_VAR"], { env: { ENV_VAR: "Wing" } });
test "exec()" {
let output = util.exec("echo", ["-n", "Hello, Wing!"]);

// exec with inherited environment variables
let output3 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo $WING_TARGET $ENV_VAR"], { inheritEnv: true });
// exec with custom environment variables
let output2 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo $WING_TARGET $ENV_VAR"], { env: { ENV_VAR: "Wing" } });

// exec with current working directory
let output4 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo Hello"], { cwd: "/tmp" });
// exec with inherited environment variables
let output3 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo $WING_TARGET $ENV_VAR"], { inheritEnv: true });

log(output);
log(output2);
log(output3);
log(output4);
// exec with custom working directory
let output4 = util.exec("bash", ["--norc", "--noprofile", "-c", "echo Hello"], { cwd: dir });

log(output);
log(output2);
log(output3);
log(output4);
}
```

```bash title="Wing console output"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions tests/doc_examples/valid/35-exec-processes.md_example_1/main.w

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 680d20f

Please sign in to comment.