| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library command_lish; | 5 library command_lish; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:json'; | 9 import 'dart:json'; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (dirExists(join(rootDir, '.git')) && gitInstalled) { | 139 if (dirExists(join(rootDir, '.git')) && gitInstalled) { |
| 140 // List all files that aren't gitignored, including those not checked | 140 // List all files that aren't gitignored, including those not checked |
| 141 // in to Git. | 141 // in to Git. |
| 142 return git.run(["ls-files", "--cached", "--others", | 142 return git.run(["ls-files", "--cached", "--others", |
| 143 "--exclude-standard"]); | 143 "--exclude-standard"]); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return listDir(rootDir, recursive: true).then((entries) { | 146 return listDir(rootDir, recursive: true).then((entries) { |
| 147 return entries | 147 return entries |
| 148 .where(fileExists) // Skip directories. | 148 .where(fileExists) // Skip directories. |
| 149 .map((entry) => relativeTo(entry, rootDir)); | 149 .map((entry) => path.relative(entry, from: rootDir)); |
| 150 }); | 150 }); |
| 151 }).then((files) => files.where(_shouldPublish).toList()); | 151 }).then((files) => files.where(_shouldPublish).toList()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 /// Returns `true` if [file] should be published. | 154 /// Returns `true` if [file] should be published. |
| 155 bool _shouldPublish(String file) { | 155 bool _shouldPublish(String file) { |
| 156 if (_BLACKLISTED_FILES.contains(basename(file))) return false; | 156 if (_BLACKLISTED_FILES.contains(path.basename(file))) return false; |
| 157 return !splitPath(file).any(_BLACKLISTED_DIRS.contains); | 157 return !path.split(file).any(_BLACKLISTED_DIRS.contains); |
| 158 } | 158 } |
| 159 | 159 |
| 160 /// Returns the value associated with [key] in [map]. Throws a user-friendly | 160 /// Returns the value associated with [key] in [map]. Throws a user-friendly |
| 161 /// error if [map] doens't contain [key]. | 161 /// error if [map] doens't contain [key]. |
| 162 _expectField(Map map, String key, http.Response response) { | 162 _expectField(Map map, String key, http.Response response) { |
| 163 if (map.containsKey(key)) return map[key]; | 163 if (map.containsKey(key)) return map[key]; |
| 164 invalidServerResponse(response); | 164 invalidServerResponse(response); |
| 165 } | 165 } |
| 166 | 166 |
| 167 /// Validates the package. Completes to false if the upload should not | 167 /// Validates the package. Completes to false if the upload should not |
| (...skipping 29 matching lines...) Expand all Loading... |
| 197 return confirm(message).then((confirmed) { | 197 return confirm(message).then((confirmed) { |
| 198 if (!confirmed) { | 198 if (!confirmed) { |
| 199 log.error("Package upload canceled."); | 199 log.error("Package upload canceled."); |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 return true; | 202 return true; |
| 203 }); | 203 }); |
| 204 }); | 204 }); |
| 205 } | 205 } |
| 206 } | 206 } |
| OLD | NEW |