Commit 93b31a41 authored by Devon Carew's avatar Devon Carew

fix flutter create

parent 9f142710
...@@ -128,21 +128,19 @@ All done! In order to run your application, type: ...@@ -128,21 +128,19 @@ All done! In order to run your application, type:
void _renderTemplates(String projectName, String dirPath, void _renderTemplates(String projectName, String dirPath,
String flutterPackagesDirectory, { bool renderDriverTest: false }) { String flutterPackagesDirectory, { bool renderDriverTest: false }) {
String relativePackagesDirectory = path.relative( new Directory(dirPath).createSync(recursive: true);
flutterPackagesDirectory,
from: path.join(dirPath, 'pubspec.yaml')
);
printStatus('Creating project ${path.basename(projectName)}:'); flutterPackagesDirectory = path.normalize(flutterPackagesDirectory);
flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
new Directory(dirPath).createSync(recursive: true); printStatus('Creating project ${path.basename(projectName)}:');
Map templateContext = <String, dynamic>{ Map templateContext = <String, dynamic>{
'projectName': projectName, 'projectName': projectName,
'androidIdentifier': _createAndroidIdentifier(projectName), 'androidIdentifier': _createAndroidIdentifier(projectName),
'iosIdentifier': _createUTIIdentifier(projectName), 'iosIdentifier': _createUTIIdentifier(projectName),
'description': description, 'description': description,
'flutterPackagesDirectory': relativePackagesDirectory, 'flutterPackagesDirectory': flutterPackagesDirectory,
'androidMinApiLevel': android.minApiLevel 'androidMinApiLevel': android.minApiLevel
}; };
...@@ -211,3 +209,11 @@ String _validateProjectName(String projectName) { ...@@ -211,3 +209,11 @@ String _validateProjectName(String projectName) {
return null; 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment