Skip to content

Commit 6b9873b

Browse files
fix: added an example file (#2330)
1 parent 945c09c commit 6b9873b

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

pkgs/process/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.0.6-wip
2+
3+
* Add an example app.
4+
15
## 5.0.5
26

37
* Fix mixtures of parentheses and spaces in windows command paths.

pkgs/process/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ Unlike `dart:io`, `package:process` requires processes to be started with
1515
spawns processes in a hermetic way.
1616

1717
[ProcessManager]: https://pub.dev/documentation/process/latest/process/ProcessManager-class.html
18+
19+
## Example
20+
21+
Run the example app from this package:
22+
23+
```bash
24+
dart run example/main.dart
25+
```

pkgs/process/example/main.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:process/process.dart';
8+
9+
Future<void> main() async {
10+
const processManager = LocalProcessManager();
11+
12+
final executable = Platform.resolvedExecutable;
13+
if (!processManager.canRun(executable)) {
14+
stderr.writeln('Unable to run: $executable');
15+
exitCode = 1;
16+
return;
17+
}
18+
19+
final result = await processManager.run([executable, '--version']);
20+
stdout.write(result.stdout);
21+
if (result.exitCode != 0) {
22+
stderr.writeln('Command failed with exit code ${result.exitCode}.');
23+
stderr.write(result.stderr);
24+
exitCode = result.exitCode;
25+
}
26+
}

0 commit comments

Comments
 (0)