mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
* Add workflow to build and deploy the sample index * update gh-pages action * fix yaml * create web/ directory in build * grammar * add ignored directories * revert pubspec.lock files * add job to run _tool/verify_samples.dart * Update filipino_cuisine for Flutter 2 * remove timeflow demo. The unnamed List constructor is now deprecated, refactoring this code to use add() requires more knowledge about the code for this demo. https://dart.dev/null-safety/understanding-null-safety#no-unnamed-list-constructor * update slide_puzzle * ensure stable channel is used to verify * move verify web demos action into separate yaml file - avoid running on each flutter version. * add on: pull_request * update slide_puzzle * Update gh-pages.yml * Add copyright header
52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
// 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');
|
||
}
|
||
|
||
Iterable<String> listPackageDirs(Directory dir) sync* {
|
||
if (File('${dir.path}/pubspec.yaml').existsSync()) {
|
||
yield dir.path;
|
||
} else {
|
||
for (var subDir in dir
|
||
.listSync(followLinks: true)
|
||
.whereType<Directory>()
|
||
.where((d) => !Uri.file(d.path).pathSegments.last.startsWith('.'))) {
|
||
yield* listPackageDirs(subDir);
|
||
}
|
||
}
|
||
}
|