diff --git a/lib/src/config.dart b/lib/src/config.dart index e7dbe4e..31ea201 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -75,8 +75,7 @@ class ScriptRunnerConfig { final sourceMap = await _tryFindConfig(fs, startDir); if (sourceMap.isEmpty) { - throw StateError( - 'Must provide scripts in either pubspec.yaml or script_runner.yaml'); + throw StateError('Must provide scripts in either pubspec.yaml or script_runner.yaml'); } final source = sourceMap.values.first; @@ -101,9 +100,7 @@ class ScriptRunnerConfig { List? scriptsRaw, { FileSystem? fileSystem, }) { - final scripts = (scriptsRaw ?? []) - .map((script) => RunnableScript.fromMap(script, fileSystem: fileSystem)) - .toList(); + final scripts = (scriptsRaw ?? []).map((script) => RunnableScript.fromMap(script, fileSystem: fileSystem)).toList(); return scripts.map((s) => s..preloadScripts = scripts).toList(); } @@ -148,8 +145,7 @@ class ScriptRunnerConfig { (configSource?.isNotEmpty == true ? [ colorize(' on ', titleStyle), - colorize( - configSource!, [...titleStyle, TerminalColor.underline]), + colorize(configSource!, [...titleStyle, TerminalColor.underline]), colorize(':', titleStyle) ].join('') : ':'), @@ -163,8 +159,7 @@ class ScriptRunnerConfig { stripColors: true, wrapLine: (line) => colorize(line, [TerminalColor.gray]), ); - printColor(' ${scr.name.padRight(padLen, ' ')} ${lines.first}', - [TerminalColor.yellow]); + printColor(' ${scr.name.padRight(padLen, ' ')} ${lines.first}', [TerminalColor.yellow]); for (final line in lines.sublist(1)) { print(' ${''.padRight(padLen, ' ')} $line'); } @@ -172,8 +167,7 @@ class ScriptRunnerConfig { } } - static Future> _tryFindConfig( - FileSystem fs, String startDir) async { + static Future> _tryFindConfig(FileSystem fs, String startDir) async { final explorer = Unaconfig('script_runner', fs: fs); final config = await explorer.search(); if (config != null) { diff --git a/lib/src/runnable_script.dart b/lib/src/runnable_script.dart index efc8008..a50b6cd 100644 --- a/lib/src/runnable_script.dart +++ b/lib/src/runnable_script.dart @@ -73,8 +73,7 @@ class RunnableScript { map['cmd'] = map.values.first; } else { map.addAll(map.cast()); - map['args'] = - (map['args'] as List?)?.map((e) => e.toString()).toList(); + map['args'] = (map['args'] as List?)?.map((e) => e.toString()).toList(); map['env'] = (map['env'] as Map?)?.cast(); } final name = map['name'] as String; @@ -97,8 +96,7 @@ class RunnableScript { appendNewline: appendNewline, ); } catch (e) { - throw StateError( - 'Failed to parse script, arguments: $map, $fileSystem. Error: $e'); + throw StateError('Failed to parse script, arguments: $map, $fileSystem. Error: $e'); } } @@ -158,8 +156,7 @@ class RunnableScript { return exitCode; } - String _getScriptPath() => _fileSystem.path - .join(_fileSystem.systemTempDirectory.path, 'script_runner_$name.sh'); + String _getScriptPath() => _fileSystem.path.join(_fileSystem.systemTempDirectory.path, 'script_runner_$name.sh'); String _getScriptContents( ScriptRunnerConfig config, { @@ -179,11 +176,8 @@ class RunnableScript { ].join('\n'); case OS.linux: case OS.macos: - return [ - ...preloadScripts.map((e) => - "[[ ! \$(which ${e.name}) ]] && alias ${e.name}='scr ${e.name}'"), - script - ].join('\n'); + return [...preloadScripts.map((e) => "[[ ! \$(which ${e.name}) ]] && alias ${e.name}='scr ${e.name}'"), script] + .join('\n'); } } } diff --git a/test/config_test.dart b/test/config_test.dart index 4a6d0ab..18cd484 100644 --- a/test/config_test.dart +++ b/test/config_test.dart @@ -147,8 +147,7 @@ Future _writeCustomConf(FileSystem fs, [String? contents]) async { final homeDir = fs.directory(Platform.environment['HOME']!); homeDir.create(recursive: true); fs.currentDirectory = homeDir; - final pubFile = - fs.file(path.join(fs.currentDirectory.path, 'script_runner.yaml')); + final pubFile = fs.file(path.join(fs.currentDirectory.path, 'script_runner.yaml')); pubFile.create(recursive: true); print('writing custom conf to ${pubFile.path}'); await pubFile.writeAsString(