Commit ef596fdb authored by Adam Barth's avatar Adam Barth

Merge pull request #456 from abarth/p_to_path

Import path.dart as path rather than p
parents b065036a cada8b3f
......@@ -8,7 +8,7 @@ import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:logging/logging.dart';
import 'package:mustache4dart/mustache4dart.dart' as mustache;
import 'package:path/path.dart' as p;
import 'package:path/path.dart' as path;
import '../artifacts.dart';
import '../process.dart';
......@@ -39,10 +39,10 @@ class InitCommand extends Command {
stderr.writeln('variable was specified. Unable to find package:flutter.');
return 2;
}
String flutterRoot = p.absolute(ArtifactStore.flutterRoot);
String flutterRoot = path.absolute(ArtifactStore.flutterRoot);
String flutterPackagePath = p.join(flutterRoot, 'packages', 'flutter');
if (!FileSystemEntity.isFileSync(p.join(flutterPackagePath, 'pubspec.yaml'))) {
String flutterPackagePath = path.join(flutterRoot, 'packages', 'flutter');
if (!FileSystemEntity.isFileSync(path.join(flutterPackagePath, 'pubspec.yaml'))) {
print('Unable to find package:flutter in $flutterPackagePath');
return 2;
}
......@@ -75,9 +75,9 @@ class InitCommand extends Command {
bool skipIfAbsent: false,
bool verbose: true
}) async {
File pubSpecYaml = new File(p.join(directory, 'pubspec.yaml'));
File pubSpecLock = new File(p.join(directory, 'pubspec.lock'));
File dotPackages = new File(p.join(directory, '.packages'));
File pubSpecYaml = new File(path.join(directory, 'pubspec.yaml'));
File pubSpecLock = new File(path.join(directory, 'pubspec.lock'));
File dotPackages = new File(path.join(directory, '.packages'));
if (!pubSpecYaml.existsSync()) {
if (skipIfAbsent)
......@@ -115,18 +115,18 @@ abstract class Template {
Template(this.name, this.description);
void generateInto(Directory dir, String flutterPackagePath) {
String dirPath = p.normalize(dir.absolute.path);
String projectName = _normalizeProjectName(p.basename(dirPath));
print('Creating ${p.basename(projectName)}...');
String dirPath = path.normalize(dir.absolute.path);
String projectName = _normalizeProjectName(path.basename(dirPath));
print('Creating ${path.basename(projectName)}...');
dir.createSync(recursive: true);
String relativeFlutterPackagePath = p.relative(flutterPackagePath, from: dirPath);
String relativeFlutterPackagePath = path.relative(flutterPackagePath, from: dirPath);
files.forEach((String path, String contents) {
files.forEach((String filePath, String contents) {
Map m = {'projectName': projectName, 'description': description, 'flutterPackagePath': relativeFlutterPackagePath};
contents = mustache.render(contents, m);
path = path.replaceAll('/', Platform.pathSeparator);
File file = new File(p.join(dir.path, path));
filePath = filePath.replaceAll('/', Platform.pathSeparator);
File file = new File(path.join(dir.path, filePath));
file.parent.createSync();
file.writeAsStringSync(contents);
print(file.path);
......
......@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:path/path.dart' as path;
import 'package:flutter_tools/src/test/json_socket.dart';
import 'package:flutter_tools/src/test/remote_test.dart';
import 'package:stack_trace/stack_trace.dart';
......@@ -55,17 +55,17 @@ Future<_ServerInfo> _createServer() async {
return new _ServerInfo(server, 'ws://$_kHost:${server.port}$_kPath', socket.future);
}
Future<Process> _startProcess(String path, { String packageRoot }) {
Future<Process> _startProcess(String mainPath, { String packageRoot }) {
assert(shellPath != null || _kSkyShell != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
return Process.start(shellPath ?? _kSkyShell, [
'--enable-checked-mode',
'--non-interactive',
'--package-root=$packageRoot',
path,
mainPath,
]);
}
Future<RunnerSuite> _loadVMFile(String path,
Future<RunnerSuite> _loadVMFile(String mainPath,
Metadata metadata,
Configuration config) async {
String encodedMetadata = Uri.encodeComponent(JSON.encode(
......@@ -81,7 +81,7 @@ import 'dart:convert';
import 'package:test/src/backend/metadata.dart';
import 'package:flutter_tools/src/test/remote_listener.dart';
import '${p.toUri(p.absolute(path))}' as test;
import '${path.toUri(path.absolute(mainPath))}' as test;
void main() {
String server = Uri.decodeComponent('${Uri.encodeComponent(info.url)}');
......@@ -96,7 +96,7 @@ void main() {
Process process = await _startProcess(
listenerFile.path,
packageRoot: p.absolute(config.packageRoot)
packageRoot: path.absolute(config.packageRoot)
);
Future cleanupTempDirectory() async {
......@@ -118,13 +118,13 @@ void main() {
case -0x0f: // ProcessSignal.SIGTERM
break; // we probably killed it ourselves
case -0x0b: // ProcessSignal.SIGSEGV
output += 'Segmentation fault in subprocess for: $path\n';
output += 'Segmentation fault in subprocess for: $mainPath\n';
break;
case -0x06: // ProcessSignal.SIGABRT
output += 'Aborted while running: $path\n';
output += 'Aborted while running: $mainPath\n';
break;
default:
output += 'Unexpected exit code $exitCode from subprocess for: $path\n';
output += 'Unexpected exit code $exitCode from subprocess for: $mainPath\n';
}
}
String stdout = await process.stdout.transform(UTF8.decoder).join('\n');
......@@ -137,7 +137,7 @@ void main() {
if (output == '')
output = 'No output.';
completer.completeError(
new LoadException(path, output),
new LoadException(mainPath, output),
new Trace.current()
);
} else {
......@@ -163,13 +163,13 @@ void main() {
} else if (response["type"] == "loadException") {
process.kill(ProcessSignal.SIGTERM);
completer.completeError(
new LoadException(path, response["message"]),
new LoadException(mainPath, response["message"]),
new Trace.current());
} else if (response["type"] == "error") {
process.kill(ProcessSignal.SIGTERM);
AsyncError asyncError = RemoteException.deserialize(response["error"]);
completer.completeError(
new LoadException(path, asyncError.error),
new LoadException(mainPath, asyncError.error),
asyncError.stackTrace);
} else {
assert(response["type"] == "success");
......@@ -186,7 +186,7 @@ void main() {
return new RunnerSuite(
const VMEnvironment(),
new Group.root(entries, metadata: metadata),
path: path,
path: mainPath,
platform: TestPlatform.vm,
os: currentOS,
onClose: () { process.kill(ProcessSignal.SIGTERM); }
......
......@@ -5,7 +5,7 @@
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as p;
import 'package:path/path.dart' as path;
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/commands/init.dart';
import 'package:flutter_tools/src/process.dart';
......@@ -37,10 +37,10 @@ defineTests() {
await runner.run(['init', '--out', temp.path])
.then((int code) => expect(code, equals(0)));
String path = p.join(temp.path, 'lib', 'main.dart');
expect(new File(path).existsSync(), true);
String mainPath = path.join(temp.path, 'lib', 'main.dart');
expect(new File(mainPath).existsSync(), true);
ProcessResult exec = Process.runSync(
sdkBinaryName('dartanalyzer'), ['--fatal-warnings', path],
sdkBinaryName('dartanalyzer'), ['--fatal-warnings', mainPath],
workingDirectory: temp.path);
if (exec.exitCode != 0) {
print(exec.stdout);
......
......@@ -6,7 +6,7 @@ import 'dart:io';
import 'package:flutter_tools/src/os_utils.dart';
import 'package:test/test.dart';
import 'package:path/path.dart' as p;
import 'package:path/path.dart' as path;
main() => defineTests();
......@@ -23,7 +23,7 @@ defineTests() {
});
test('makeExecutable', () {
File file = new File(p.join(temp.path, 'foo.script'));
File file = new File(path.join(temp.path, 'foo.script'));
file.writeAsStringSync('hello world');
osUtils.makeExecutable(file);
......
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