Merge pull request #2437 from devoncarew/fix_create

fix flutter create
This commit is contained in:
Devon Carew 2016-03-05 07:01:47 -08:00
commit 93a0fb44c7

View File

@ -128,21 +128,19 @@ All done! In order to run your application, type:
void _renderTemplates(String projectName, String dirPath,
String flutterPackagesDirectory, { bool renderDriverTest: false }) {
String relativePackagesDirectory = path.relative(
flutterPackagesDirectory,
from: path.join(dirPath, 'pubspec.yaml')
);
new Directory(dirPath).createSync(recursive: true);
flutterPackagesDirectory = path.normalize(flutterPackagesDirectory);
flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
printStatus('Creating project ${path.basename(projectName)}:');
new Directory(dirPath).createSync(recursive: true);
Map templateContext = <String, dynamic>{
'projectName': projectName,
'androidIdentifier': _createAndroidIdentifier(projectName),
'iosIdentifier': _createUTIIdentifier(projectName),
'description': description,
'flutterPackagesDirectory': relativePackagesDirectory,
'flutterPackagesDirectory': flutterPackagesDirectory,
'androidMinApiLevel': android.minApiLevel
};
@ -211,3 +209,11 @@ String _validateProjectName(String projectName) {
return null;
}
String _relativePath({ String from, String to }) {
String result = path.relative(to, from: from);
// `path.relative()` doesn't always return a correct result: dart-lang/path#12.
if (FileSystemEntity.isDirectorySync(path.join(from, result)))
return result;
return to;
}