process_plus 2.0.0

process_plus #

Pub build status

Helpers for package:process. Including ForwardingProcessManager, PooledProcessManager, MockProcessManager, and CompletedProcess.

ForwardingProcessManager #

A simple ProcessManager that delegates to another one. Typically used as a base class to extend functionality.

var manager = ForwwardingProcessManager(const LocalProcessManager());

PooledProcessManager #

A ProcessManager that uses a Pool to limit to the max amount of concurrently-running processes.

var manager = PooledProcessManager(const LocalProcessManager(), Platform.numberOfProcessors);

MockProcessManager #

A ProcessManager that can enqueue results in advance, rather than actually spawning OS processes.

var manager = MockProcessManager();
manager.enqueue(ProcessResult(0, 1337, stdout, stderr));

var p = await manager.run(['foo', '--bar=baz']);
await p.exitCode; // 1337

CompletedProcess #

A Process implementation that simply outputs the result of a CompletedProcess.

var p = CompletedProcess(ProcessResult(0, 1337, stdout, stderr));
await p.exitCode; // 1337

2.0.0 #

  • Dart 2 update.

example/main.dart

import 'dart:io';
import 'package:process_plus/process_plus.dart';
import 'package:test/test.dart';
import 'completed_process.dart';

void main() {
  var r = ProcessResult(0, 0, hello, world);
  MockProcessManager manager;

  setUp(() async {
    manager = MockProcessManager();
  });

  test('canRun', () {
    manager..enqueueCanRun(true)..enqueueCanRun(false);
    expect(manager.canRun('foo'), true);
    expect(manager.canRun('foo'), false);
  });

  test('kill', () {
    manager..enqueueKill(true)..enqueueKill(false);
    expect(manager.killPid(0), true);
    expect(manager.killPid(0), false);
  });

  test('queue process', () async {
    manager.enqeueProcess(CompletedProcess(r));
    var p = await manager.start(['foo']);
    expect(await p.pid, r.pid);
    expect(await p.exitCode, r.exitCode);
    expect(await p.stdout.first, hello);
    expect(await p.stderr.first, world);
  });

  group('queue process result', () {
    setUp(() async {
      manager..enqeue(r)..enqeue(r);
    });

    test('runSync', () => expect(manager.runSync(['foo']), r));
    test('run', () async => expect(await manager.run(['foo']), r));
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  process_plus: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:process_plus/process_plus.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
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]
50
Learn more about scoring.

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

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
pool ^1.0.0 1.4.0
process ^3.0.0 3.0.12
Transitive dependencies
async 2.3.0
collection 1.14.12
file 5.0.10
intl 0.16.0
meta 1.1.7
path 1.6.4
platform 2.2.1
stack_trace 1.9.3
Dev dependencies
pedantic ^1.0.0
test ^1.0.0