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