process_run 0.9.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 79

process_run.dart #

Process run helpers for Linux/Win/Mac, which like feature

Build Status

Goals #

Currently using Process.run does not stream output which is not convenient for lenthy operation. It requires using Process.start in a more complex way. run and runCmd add verbose helper for that. Also dart binaries (pub, dart2js...) can be called consistently on Mac/Windows/Linux

ProcessCmd allow creating command object that can be run and modified

Usage #

process_run #

Additional options to Process.run are

  • specifying stdin
  • making it verbose

dartbin #

Helper to format dart binaries argument that works cross-platforms

  • dart2js
  • pub
  • dartfmt
  • dartanalyzer
  • dartoc
  • dartdevc

process_cmd #

Allow creating ProcessCmd object that can be run in different manner

which #

Like unix which, it searches for installed executables

var flutterExectutable = whichSync('flutter');
var firebaseExectutable = whichSync('firebase');

Sample usage #

Using ProcessCmd #

import 'dart:io';
import 'package:process_run/cmd_run.dart';

main() async {
  // Simple echo command
  // Somehow windows requires runInShell for the system commands
  bool runInShell = Platform.isWindows;

  // Run the command
  ProcessCmd cmd = processCmd('echo', ['hello world'], runInShell: runInShell);
  await runCmd(cmd);

  // Running the command in verbose mode (i.e. display the command and stdout/stderr)
  // > $ echo "hello world"
  // > hello world
  await runCmd(cmd, verbose: true);

  // Stream the out to stdout
  await runCmd(cmd, stdout: stdout);

  // Calling dart
  cmd = DartCmd(['--version']);
  await runCmd(cmd);

  // clone the command to allow other modifications
  cmd = processCmd('echo', ['hello world'], runInShell: runInShell);
  // > $ echo "hello world"
  // > hello world
  await runCmd(cmd, verbose: true);
  // > $ echo "new hello world"
  // > new hello world
  await runCmd(cmd.clone()
    ..arguments = ["new hello world"], verbose: true);

  // Calling dart
  // > $ dart --version
  // > Dart VM version: 1.19.1 (Wed Sep  7 15:59:44 2016) on "linux_x64"
  cmd = DartCmd(['--version']);
  await runCmd(cmd, verbose: true);

  // Calling dart script
  // $ dart example/my_script.dart my_first_arg my_second_arg
  await runCmd(DartCmd(['example/my_script.dart', 'my_first_arg', 'my_second_arg']), commandVerbose: true);

  // Calling pub
  // > $ pub --version
  // > Pub 1.19.1
  await runCmd(PubCmd(['--version']), verbose: true);

  // Listing global activated packages
  // > $ pub global list
  // > ...
  await runCmd(PubCmd(['global', 'list']), verbose: true);
}

Low level #

import 'dart:io';

import 'package:process_run/process_run.dart';
import 'package:process_run/dartbin.dart';

main() async {
  // Simple echo command
  // Somehow windows requires runInShell for the system commands
  bool runInShell = Platform.isWindows;

  // Run the command
  await run('echo', ['hello world'], runInShell: runInShell);

  // Stream the out to stdout
  await run('echo', ['hello world'], runInShell: runInShell, stdout: stdout);

  // Calling dart
  await run(dartExecutable, ['--version']);

  // stream the output to stderr
  await run(dartExecutable, ['--version'], stderr: stderr);

  // Listing global activated packages
  await run(dartExecutable, pubArguments(['global', 'list']), verbose: true);
}

Limitations #

As noted in the example, windows requires runInShell for system commands (echo, type) but not for regular executables (dart, git...)

Changelog #

0.9.0 #

  • fix: which now returns the full path on linux

0.8.0 #

  • Deprecate old commands helper dartCmd, pubCmd... to use constructors instead (DartCmd, PubCmd...)
  • Add webdev and pbr command

0.7.0 #

  • add flutter command support
  • add Windows support
  • add which utility

0.6.0 #

  • dart2 support

0.5.6 #

  • supports implicit-casts: false

0.5.5 #

  • when using io.stdout and io.stderr, flush them when running a command

0.5.4 #

  • Fix handling of stdin

0.5.2 #

  • fix dart2js to have a libraryRoot argument
  • add dartdevc

0.5.1 #

  • fix devRun

0.5.0 #

  • deprecated connectStdout and connectStrerr in ProcessCmd
  • add stdin, stdout, verbose and commandVerbose parameter for run

0.4.0 #

  • add stdin and deprecated buggy connectStdin

0.3.3 #

  • add argumentToString to handle basic quote or double quote

0.3.2 #

  • fix dartdoc to add --packages argument along with the snapshot

0.3.0 #

  • Add runCmd (cmd_run library)

0.2.0 #

  • Add ProcessCmd

0.1.0 #

  • Initial version, run and dartbin utilities

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  process_run: ^0.9.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:process_run/process_run.dart';
  
Version Uploaded Documentation Archive
0.9.0 Feb 6, 2019 Go to the documentation of process_run 0.9.0 Download process_run 0.9.0 archive
0.8.1 Jan 16, 2019 Go to the documentation of process_run 0.8.1 Download process_run 0.8.1 archive
0.8.0+1 Oct 10, 2018 Go to the documentation of process_run 0.8.0+1 Download process_run 0.8.0+1 archive
0.8.0 Oct 10, 2018 Go to the documentation of process_run 0.8.0 Download process_run 0.8.0 archive
0.7.0+2 Oct 8, 2018 Go to the documentation of process_run 0.7.0+2 Download process_run 0.7.0+2 archive
0.7.0+1 Oct 8, 2018 Go to the documentation of process_run 0.7.0+1 Download process_run 0.7.0+1 archive
0.7.0 Sep 18, 2018 Go to the documentation of process_run 0.7.0 Download process_run 0.7.0 archive
0.6.0+2 Sep 18, 2018 Go to the documentation of process_run 0.6.0+2 Download process_run 0.6.0+2 archive
0.6.0+1 Jul 24, 2018 Go to the documentation of process_run 0.6.0+1 Download process_run 0.6.0+1 archive
0.6.0 Jul 24, 2018 Go to the documentation of process_run 0.6.0 Download process_run 0.6.0 archive

All 25 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1

Platforms

Detected platforms: Flutter, other

Primary library: package:process_run/process_run.dart with components: io.

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and process_run.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58 <3.0.0
collection >=1.14.10 <3.0.0 1.14.11
path >=1.6.1 <3.0.0 1.6.2
Dev dependencies
args any
async any
build_runner >=0.9.0
build_test >=0.10.2
dev_test any
pedantic >=1.4.0
pub_semver any
test >=1.2.0