1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
Files
samples/web/_tool/common.dart
John Ryan 0a5a5109de Add samples index (#359)
* add samples_index to web/ directory

Co-authored-by: Thea Flowers <theaflowers@google.com>

* add pub_get.dart script

* build sample index in peanut post build

* re-generate sample index with web demos

* print more details in peanut_post_build.dart

* add images for demos

* run generator

* update README

* add animations and provider shopper as symlinks

* add links to symlinked web demos

* use relative paths

* update cookbook images, urls, and description CSS

* use relative URL for navbar link

* unstage HTML files

* .gitignore generated HTML files

* add margin to toolbar

* rename escape functions

* add and update copyright headers

Co-authored-by: Thea Flowers <theaflowers@google.com>
2020-03-09 16:17:08 -07:00

39 lines
1.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file
import 'dart:io';
const ansiGreen = 32;
const ansiRed = 31;
const ansiMagenta = 35;
Future<bool> run(
String workingDir, String commandName, List<String> args) async {
var commandDescription = '`${([commandName]..addAll(args)).join(' ')}`';
logWrapped(ansiMagenta, ' Running $commandDescription');
var proc = await Process.start(
commandName,
args,
workingDirectory: Directory.current.path + '/' + workingDir,
mode: ProcessStartMode.inheritStdio,
);
var exitCode = await proc.exitCode;
if (exitCode != 0) {
logWrapped(
ansiRed, ' Failed! ($exitCode) $workingDir $commandDescription');
return false;
} else {
logWrapped(ansiGreen, ' Success! $workingDir $commandDescription');
return true;
}
}
void logWrapped(int code, String message) {
print('\x1B[${code}m$message\x1B[0m');
}