Skip to content

Commit d97f381

Browse files
committed
chore: format
1 parent 00c5ae4 commit d97f381

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

lib/src/config.dart

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ class ScriptRunnerConfig {
7575
final sourceMap = await _tryFindConfig(fs, startDir);
7676

7777
if (sourceMap.isEmpty) {
78-
throw StateError(
79-
'Must provide scripts in either pubspec.yaml or script_runner.yaml');
78+
throw StateError('Must provide scripts in either pubspec.yaml or script_runner.yaml');
8079
}
8180

8281
final source = sourceMap.values.first;
@@ -101,9 +100,7 @@ class ScriptRunnerConfig {
101100
List<dynamic>? scriptsRaw, {
102101
FileSystem? fileSystem,
103102
}) {
104-
final scripts = (scriptsRaw ?? [])
105-
.map((script) => RunnableScript.fromMap(script, fileSystem: fileSystem))
106-
.toList();
103+
final scripts = (scriptsRaw ?? []).map((script) => RunnableScript.fromMap(script, fileSystem: fileSystem)).toList();
107104
return scripts.map((s) => s..preloadScripts = scripts).toList();
108105
}
109106

@@ -148,8 +145,7 @@ class ScriptRunnerConfig {
148145
(configSource?.isNotEmpty == true
149146
? [
150147
colorize(' on ', titleStyle),
151-
colorize(
152-
configSource!, [...titleStyle, TerminalColor.underline]),
148+
colorize(configSource!, [...titleStyle, TerminalColor.underline]),
153149
colorize(':', titleStyle)
154150
].join('')
155151
: ':'),
@@ -163,17 +159,15 @@ class ScriptRunnerConfig {
163159
stripColors: true,
164160
wrapLine: (line) => colorize(line, [TerminalColor.gray]),
165161
);
166-
printColor(' ${scr.name.padRight(padLen, ' ')} ${lines.first}',
167-
[TerminalColor.yellow]);
162+
printColor(' ${scr.name.padRight(padLen, ' ')} ${lines.first}', [TerminalColor.yellow]);
168163
for (final line in lines.sublist(1)) {
169164
print(' ${''.padRight(padLen, ' ')} $line');
170165
}
171166
print('');
172167
}
173168
}
174169

175-
static Future<Map<String, Map>> _tryFindConfig(
176-
FileSystem fs, String startDir) async {
170+
static Future<Map<String, Map>> _tryFindConfig(FileSystem fs, String startDir) async {
177171
final explorer = Unaconfig('script_runner', fs: fs);
178172
final config = await explorer.search();
179173
if (config != null) {

lib/src/runnable_script.dart

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class RunnableScript {
7373
map['cmd'] = map.values.first;
7474
} else {
7575
map.addAll(map.cast<String, dynamic>());
76-
map['args'] =
77-
(map['args'] as List?)?.map((e) => e.toString()).toList();
76+
map['args'] = (map['args'] as List?)?.map((e) => e.toString()).toList();
7877
map['env'] = (map['env'] as Map?)?.cast<String, String>();
7978
}
8079
final name = map['name'] as String;
@@ -97,8 +96,7 @@ class RunnableScript {
9796
appendNewline: appendNewline,
9897
);
9998
} catch (e) {
100-
throw StateError(
101-
'Failed to parse script, arguments: $map, $fileSystem. Error: $e');
99+
throw StateError('Failed to parse script, arguments: $map, $fileSystem. Error: $e');
102100
}
103101
}
104102

@@ -158,8 +156,7 @@ class RunnableScript {
158156
return exitCode;
159157
}
160158

161-
String _getScriptPath() => _fileSystem.path
162-
.join(_fileSystem.systemTempDirectory.path, 'script_runner_$name.sh');
159+
String _getScriptPath() => _fileSystem.path.join(_fileSystem.systemTempDirectory.path, 'script_runner_$name.sh');
163160

164161
String _getScriptContents(
165162
ScriptRunnerConfig config, {
@@ -179,11 +176,8 @@ class RunnableScript {
179176
].join('\n');
180177
case OS.linux:
181178
case OS.macos:
182-
return [
183-
...preloadScripts.map((e) =>
184-
"[[ ! \$(which ${e.name}) ]] && alias ${e.name}='scr ${e.name}'"),
185-
script
186-
].join('\n');
179+
return [...preloadScripts.map((e) => "[[ ! \$(which ${e.name}) ]] && alias ${e.name}='scr ${e.name}'"), script]
180+
.join('\n');
187181
}
188182
}
189183
}

test/config_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ Future<void> _writeCustomConf(FileSystem fs, [String? contents]) async {
147147
final homeDir = fs.directory(Platform.environment['HOME']!);
148148
homeDir.create(recursive: true);
149149
fs.currentDirectory = homeDir;
150-
final pubFile =
151-
fs.file(path.join(fs.currentDirectory.path, 'script_runner.yaml'));
150+
final pubFile = fs.file(path.join(fs.currentDirectory.path, 'script_runner.yaml'));
152151
pubFile.create(recursive: true);
153152
print('writing custom conf to ${pubFile.path}');
154153
await pubFile.writeAsString(

0 commit comments

Comments
 (0)