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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 /// The basenames of directories that are automatically excluded from | 110 /// The basenames of directories that are automatically excluded from |
111 /// archives. | 111 /// archives. |
112 final _BLACKLISTED_DIRECTORIES = const ['packages']; | 112 final _BLACKLISTED_DIRECTORIES = const ['packages']; |
113 | 113 |
114 /// Returns a list of files that should be included in the published package. | 114 /// Returns a list of files that should be included in the published package. |
115 /// If this is a Git repository, this will respect .gitignore; otherwise, it | 115 /// If this is a Git repository, this will respect .gitignore; otherwise, it |
116 /// will return all non-hidden files. | 116 /// will return all non-hidden files. |
117 Future<List<String>> get _filesToPublish { | 117 Future<List<String>> get _filesToPublish { |
118 var rootDir = entrypoint.root.dir; | 118 var rootDir = entrypoint.root.dir; |
119 | 119 |
120 return Futures.wait([ | 120 return Future.wait([ |
121 dirExists(join(rootDir, '.git')), | 121 dirExists(join(rootDir, '.git')), |
122 git.isInstalled | 122 git.isInstalled |
123 ]).then((results) { | 123 ]).then((results) { |
124 if (results[0] && results[1]) { | 124 if (results[0] && results[1]) { |
125 // List all files that aren't gitignored, including those not checked | 125 // List all files that aren't gitignored, including those not checked |
126 // in to Git. | 126 // in to Git. |
127 return git.run(["ls-files", "--cached", "--others", | 127 return git.run(["ls-files", "--cached", "--others", |
128 "--exclude-standard"]); | 128 "--exclude-standard"]); |
129 } | 129 } |
130 | 130 |
131 return listDir(rootDir, recursive: true).then((entries) { | 131 return listDir(rootDir, recursive: true).then((entries) { |
132 return Futures.wait(entries.mappedBy((entry) { | 132 return Future.wait(entries.mappedBy((entry) { |
133 return fileExists(entry).then((isFile) { | 133 return fileExists(entry).then((isFile) { |
134 // Skip directories. | 134 // Skip directories. |
135 if (!isFile) return null; | 135 if (!isFile) return null; |
136 | 136 |
137 // TODO(rnystrom): Making these relative will break archive | 137 // TODO(rnystrom): Making these relative will break archive |
138 // creation if the cwd is ever *not* the package root directory. | 138 // creation if the cwd is ever *not* the package root directory. |
139 // Should instead only make these relative right before generating | 139 // Should instead only make these relative right before generating |
140 // the tree display (which is what really needs them to be). | 140 // the tree display (which is what really needs them to be). |
141 // Make it relative to the package root. | 141 // Make it relative to the package root. |
142 return relativeTo(entry, rootDir); | 142 return relativeTo(entry, rootDir); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 var s = warnings.length == 1 ? '' : 's'; | 178 var s = warnings.length == 1 ? '' : 's'; |
179 message = "Package has ${warnings.length} warning$s. Upload anyway"; | 179 message = "Package has ${warnings.length} warning$s. Upload anyway"; |
180 } | 180 } |
181 | 181 |
182 return confirm(message).then((confirmed) { | 182 return confirm(message).then((confirmed) { |
183 if (!confirmed) throw "Package upload canceled."; | 183 if (!confirmed) throw "Package upload canceled."; |
184 }); | 184 }); |
185 }); | 185 }); |
186 } | 186 } |
187 } | 187 } |
OLD | NEW |