process_run 0.5.6

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 65

process_run.dart

Process run helpers for Linux/Win/Mac

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

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.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.5.6"

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.5.6 Mar 1, 2018 Go to the documentation of process_run 0.5.6 Download process_run 0.5.6 archive
0.5.5 Oct 25, 2017 Go to the documentation of process_run 0.5.5 Download process_run 0.5.5 archive
0.5.4 Sep 26, 2017 Go to the documentation of process_run 0.5.4 Download process_run 0.5.4 archive
0.5.2 Sep 4, 2017 Go to the documentation of process_run 0.5.2 Download process_run 0.5.2 archive
0.5.1 Jun 25, 2017 Go to the documentation of process_run 0.5.1 Download process_run 0.5.1 archive
0.5.0+1 Oct 11, 2016 Go to the documentation of process_run 0.5.0+1 Download process_run 0.5.0+1 archive
0.5.0 Sep 28, 2016 Go to the documentation of process_run 0.5.0 Download process_run 0.5.0 archive
0.3.2 Jan 22, 2016 Go to the documentation of process_run 0.3.2 Download process_run 0.3.2 archive
0.3.1 Dec 9, 2015 Go to the documentation of process_run 0.3.1 Download process_run 0.3.1 archive
0.3.0 Dec 9, 2015 Go to the documentation of process_run 0.3.0 Download process_run 0.3.0 archive

All 13 versions...

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, other

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

Suggestions

  • Use constrained dependencies.

    The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: collection, path.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 hints.

    Strong-mode analysis of lib/process_run.dart gave the following hint:

    line: 95 col: 30
    'SYSTEM_ENCODING' is deprecated and shouldn't be used.

    Strong-mode analysis of lib/src/process_cmd.dart gave the following hint:

    line: 25 col: 28
    'SYSTEM_ENCODING' is deprecated and shouldn't be used.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use process_run.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.2 <2.0.0
collection >=1.9.1 1.14.10
path >=1.3.9 1.6.1
Dev dependencies
args any
async any
dev_test any
func any
pub_semver any
test any