| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "dart:async"; | 5 import "dart:async"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 import "dart:convert" show JSON; | 7 import "dart:convert" show JSON; |
| 8 import "package:path/path.dart" as p; | 8 import "package:path/path.dart" as p; |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 | 10 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 String httpUri = | 238 String httpUri = |
| 239 "http://${httpServer.address.address}:${httpServer.port}/$id/"; | 239 "http://${httpServer.address.address}:${httpServer.port}/$id/"; |
| 240 | 240 |
| 241 String fixPath(String path) { | 241 String fixPath(String path) { |
| 242 return path?.replaceAllMapped(fileHttpRegexp, (match) { | 242 return path?.replaceAllMapped(fileHttpRegexp, (match) { |
| 243 if (path.startsWith("%file/", match.start)) return fileUri; | 243 if (path.startsWith("%file/", match.start)) return fileUri; |
| 244 return httpUri; | 244 return httpUri; |
| 245 }); | 245 }); |
| 246 } | 246 } |
| 247 | 247 |
| 248 String fixPaths(Map dirs) { | 248 void fixPaths(Map dirs) { |
| 249 for (var name in dirs.keys) { | 249 for (var name in dirs.keys) { |
| 250 var value = dirs[name]; | 250 var value = dirs[name]; |
| 251 if (value is Map) { | 251 if (value is Map) { |
| 252 Map subDir = value; | 252 Map subDir = value; |
| 253 fixPaths(subDir); | 253 fixPaths(subDir); |
| 254 } else { | 254 } else { |
| 255 var newValue = fixPath(value); | 255 var newValue = fixPath(value); |
| 256 if (newValue != value) dirs[name] = newValue; | 256 if (newValue != value) dirs[name] = newValue; |
| 257 } | 257 } |
| 258 } | 258 } |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 List<String> args, | 927 List<String> args, |
| 928 List<String> newArgs, | 928 List<String> newArgs, |
| 929 Map expect | 929 Map expect |
| 930 }) { | 930 }) { |
| 931 return new Configuration( | 931 return new Configuration( |
| 932 description: description ?? this.description, | 932 description: description ?? this.description, |
| 933 root: root ?? this.root, | 933 root: root ?? this.root, |
| 934 config: config ?? this.config, | 934 config: config ?? this.config, |
| 935 mainFile: mainFile ?? | 935 mainFile: mainFile ?? |
| 936 ((main == null) ? this.mainFile : "${this.mainPath}$main.dart"), | 936 ((main == null) ? this.mainFile : "${this.mainPath}$main.dart"), |
| 937 args: args ?? ([]..addAll(newArgs ?? const [])..addAll(this.args)), | 937 args: |
| 938 args ?? (<String>[]..addAll(newArgs ?? const <String>[]) |
| 939 ..addAll(this.args)), |
| 938 expect: expect == null | 940 expect: expect == null |
| 939 ? this.expect | 941 ? this.expect |
| 940 : new Map.from(this.expect)..addAll(expect ?? const {})); | 942 : new Map.from(this.expect)..addAll(expect ?? const {})); |
| 941 } | 943 } |
| 942 | 944 |
| 943 // For debugging. | 945 // For debugging. |
| 944 String toString() { | 946 String toString() { |
| 945 return "Configuration($description\n" | 947 return "Configuration($description\n" |
| 946 " root : $root\n" | 948 " root : $root\n" |
| 947 " config: $config\n" | 949 " config: $config\n" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 964 void insertFileAt(Map file, Map http, | 966 void insertFileAt(Map file, Map http, |
| 965 String path, String name, String content) { | 967 String path, String name, String content) { |
| 966 var parts = path.split('/').toList(); | 968 var parts = path.split('/').toList(); |
| 967 var dir = (parts[0] == "%file") ? file : http; | 969 var dir = (parts[0] == "%file") ? file : http; |
| 968 for (var i = 1; i < parts.length - 1; i++) { | 970 for (var i = 1; i < parts.length - 1; i++) { |
| 969 var entry = parts[i]; | 971 var entry = parts[i]; |
| 970 dir = dir[entry] ?? (dir[entry] = {}); | 972 dir = dir[entry] ?? (dir[entry] = {}); |
| 971 } | 973 } |
| 972 dir[name] = content; | 974 dir[name] = content; |
| 973 } | 975 } |
| OLD | NEW |