@@ -5,7 +5,6 @@ import 'package:file/local.dart';
55import 'package:script_runner/src/config.dart' ;
66// ignore: no_leading_underscores_for_library_prefixes
77import 'package:script_runner/src/utils.dart' as _utils;
8- import 'package:yaml/yaml.dart' as yaml;
98
109/// A runnable script with pre-defined name, cmd and args. May be run using the `run` command and optionally
1110/// supplying extra arguments to pass.
@@ -64,33 +63,20 @@ class RunnableScript {
6463 this .appendNewline = false ,
6564 }) : _fileSystem = fileSystem ?? LocalFileSystem ();
6665
67- /// Generate a runnable script from a yaml loaded map as defined in the config.
68- factory RunnableScript .fromYamlMap (yaml.YamlMap map,
69- {FileSystem ? fileSystem}) {
70- final out = < String , dynamic > {};
71-
72- if (map['name' ] == null && map.keys.length == 1 ) {
73- out['name' ] = map.keys.first;
74- out['cmd' ] = map.values.first;
75- } else {
76- out.addAll (map.cast <String , dynamic >());
77- out['args' ] =
78- (map['args' ] as yaml.YamlList ? )? .map ((e) => e.toString ()).toList ();
79- out['env' ] = (map['env' ] as yaml.YamlMap ? )? .cast <String , String >();
80- }
81- try {
82- return RunnableScript .fromMap (out, fileSystem: fileSystem);
83- } catch (e) {
84- throw StateError (
85- 'Failed to parse script, arguments: $map , $fileSystem . Error: $e ' );
86- }
87- }
88-
8966 /// Generate a runnable script from a normal map as defined in the config.
9067 factory RunnableScript .fromMap (
9168 Map <String , dynamic > map, {
9269 FileSystem ? fileSystem,
9370 }) {
71+ if (map['name' ] == null && map.keys.length == 1 ) {
72+ map['name' ] = map.keys.first;
73+ map['cmd' ] = map.values.first;
74+ } else {
75+ map.addAll (map.cast <String , dynamic >());
76+ map['args' ] =
77+ (map['args' ] as List ? )? .map ((e) => e.toString ()).toList ();
78+ map['env' ] = (map['env' ] as Map ? )? .cast <String , String >();
79+ }
9480 final name = map['name' ] as String ;
9581 final rawCmd = map['cmd' ] as String ;
9682 final cmd = rawCmd;
0 commit comments