Commit 5e54fd54 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Ban package:path from Flutter Tools (#8119)

parent 9df8b721
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart';
import '../base/common.dart';
......@@ -69,20 +68,20 @@ class AndroidSdk {
androidHomeDir = platform.environment[kAndroidHome];
} else if (platform.isLinux) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'Android', 'Sdk');
androidHomeDir = fs.path.join(homeDirPath, 'Android', 'Sdk');
} else if (platform.isMacOS) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'Library', 'Android', 'sdk');
androidHomeDir = fs.path.join(homeDirPath, 'Library', 'Android', 'sdk');
} else if (platform.isWindows) {
if (homeDirPath != null)
androidHomeDir = path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
androidHomeDir = fs.path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
}
if (androidHomeDir != null) {
if (validSdkDirectory(androidHomeDir))
return new AndroidSdk(androidHomeDir);
if (validSdkDirectory(path.join(androidHomeDir, 'sdk')))
return new AndroidSdk(path.join(androidHomeDir, 'sdk'));
if (validSdkDirectory(fs.path.join(androidHomeDir, 'sdk')))
return new AndroidSdk(fs.path.join(androidHomeDir, 'sdk'));
}
File aaptBin = os.which('aapt'); // in build-tools/$version/aapt
......@@ -109,7 +108,7 @@ class AndroidSdk {
}
static bool validSdkDirectory(String dir) {
return fs.isDirectorySync(path.join(dir, 'platform-tools'));
return fs.isDirectorySync(fs.path.join(dir, 'platform-tools'));
}
List<AndroidSdkVersion> get sdkVersions => _sdkVersions;
......@@ -131,30 +130,30 @@ class AndroidSdk {
}
String getPlatformToolsPath(String binaryName) {
return path.join(directory, 'platform-tools', binaryName);
return fs.path.join(directory, 'platform-tools', binaryName);
}
void _init() {
List<String> platforms = <String>[]; // android-22, ...
Directory platformsDir = fs.directory(path.join(directory, 'platforms'));
Directory platformsDir = fs.directory(fs.path.join(directory, 'platforms'));
if (platformsDir.existsSync()) {
platforms = platformsDir
.listSync()
.map((FileSystemEntity entity) => path.basename(entity.path))
.map((FileSystemEntity entity) => fs.path.basename(entity.path))
.where((String name) => name.startsWith('android-'))
.toList();
}
List<Version> buildTools = <Version>[]; // 19.1.0, 22.0.1, ...
Directory buildToolsDir = fs.directory(path.join(directory, 'build-tools'));
Directory buildToolsDir = fs.directory(fs.path.join(directory, 'build-tools'));
if (buildToolsDir.existsSync()) {
buildTools = buildToolsDir
.listSync()
.map((FileSystemEntity entity) {
try {
return new Version.parse(path.basename(entity.path));
return new Version.parse(fs.path.basename(entity.path));
} catch (error) {
return null;
}
......@@ -243,11 +242,11 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
}
String getPlatformsPath(String itemName) {
return path.join(sdk.directory, 'platforms', platformVersionName, itemName);
return fs.path.join(sdk.directory, 'platforms', platformVersionName, itemName);
}
String getBuildToolsPath(String binaryName) {
return path.join(sdk.directory, 'build-tools', buildToolsVersionName, binaryName);
return fs.path.join(sdk.directory, 'build-tools', buildToolsVersionName, binaryName);
}
@override
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
......@@ -83,7 +81,7 @@ String _locateSystemGradle() {
if (gradleDir != null) {
if (fs.isFileSync(gradleDir))
return gradleDir;
return path.join(gradleDir, 'bin', 'gradle');
return fs.path.join(gradleDir, 'bin', 'gradle');
}
// Look relative to Android Studio.
......@@ -98,14 +96,14 @@ String _locateSystemGradle() {
if (studioPath != null) {
// '/Applications/Android Studio.app/Contents/gradle/gradle-2.10/bin/gradle'
if (os.isMacOS && !studioPath.endsWith('Contents'))
studioPath = path.join(studioPath, 'Contents');
studioPath = fs.path.join(studioPath, 'Contents');
Directory dir = fs.directory(path.join(studioPath, 'gradle'));
Directory dir = fs.directory(fs.path.join(studioPath, 'gradle'));
if (dir.existsSync()) {
// We find the first valid gradle directory.
for (FileSystemEntity entity in dir.listSync()) {
if (entity is Directory && path.basename(entity.path).startsWith('gradle-')) {
String executable = path.join(entity.path, 'bin', 'gradle');
if (entity is Directory && fs.path.basename(entity.path).startsWith('gradle-')) {
String executable = fs.path.join(entity.path, 'bin', 'gradle');
if (fs.isFileSync(executable))
return executable;
}
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'package:xml/xml.dart' as xml;
import 'android/android_sdk.dart';
......@@ -86,8 +85,8 @@ class AndroidApk extends ApplicationPackage {
manifestPath = gradleManifestPath;
apkPath = gradleAppOut;
} else {
manifestPath = path.join('android', 'AndroidManifest.xml');
apkPath = path.join(getAndroidBuildDirectory(), 'app.apk');
manifestPath = fs.path.join('android', 'AndroidManifest.xml');
apkPath = fs.path.join(getAndroidBuildDirectory(), 'app.apk');
}
if (!fs.isFileSync(manifestPath))
......@@ -125,7 +124,7 @@ class AndroidApk extends ApplicationPackage {
String get packagePath => apkPath;
@override
String get name => path.basename(apkPath);
String get name => fs.path.basename(apkPath);
}
/// Tests whether a [FileSystemEntity] is an iOS bundle directory
......@@ -142,14 +141,14 @@ abstract class IOSApp extends ApplicationPackage {
Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_app_');
addShutdownHook(() async => await tempDir.delete(recursive: true));
os.unzip(fs.file(applicationBinary), tempDir);
Directory payloadDir = fs.directory(path.join(tempDir.path, 'Payload'));
Directory payloadDir = fs.directory(fs.path.join(tempDir.path, 'Payload'));
bundleDir = payloadDir.listSync().singleWhere(_isBundleDirectory);
} on StateError catch (e, stackTrace) {
printError('Invalid prebuilt iOS binary: ${e.toString()}', stackTrace);
return null;
}
String plistPath = path.join(bundleDir.path, 'Info.plist');
String plistPath = fs.path.join(bundleDir.path, 'Info.plist');
String id = plist.getValueFromFile(plistPath, plist.kCFBundleIdentifierKey);
if (id == null)
return null;
......@@ -157,7 +156,7 @@ abstract class IOSApp extends ApplicationPackage {
return new PrebuiltIOSApp(
ipaPath: applicationBinary,
bundleDir: bundleDir,
bundleName: path.basename(bundleDir.path),
bundleName: fs.path.basename(bundleDir.path),
projectBundleId: id,
);
}
......@@ -166,15 +165,15 @@ abstract class IOSApp extends ApplicationPackage {
if (getCurrentHostPlatform() != HostPlatform.darwin_x64)
return null;
String plistPath = path.join('ios', 'Runner', 'Info.plist');
String plistPath = fs.path.join('ios', 'Runner', 'Info.plist');
String id = plist.getValueFromFile(plistPath, plist.kCFBundleIdentifierKey);
if (id == null)
return null;
String projectPath = path.join('ios', 'Runner.xcodeproj');
String projectPath = fs.path.join('ios', 'Runner.xcodeproj');
id = substituteXcodeVariables(id, projectPath, 'Runner');
return new BuildableIOSApp(
appDirectory: path.join('ios'),
appDirectory: fs.path.join('ios'),
projectBundleId: id
);
}
......@@ -207,7 +206,7 @@ class BuildableIOSApp extends IOSApp {
String get deviceBundlePath => _buildAppPath('iphoneos');
String _buildAppPath(String type) {
return path.join(getIosBuildDirectory(), 'Release-$type', kBundleName);
return fs.path.join(getIosBuildDirectory(), 'Release-$type', kBundleName);
}
}
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert';
import 'package:json_schema/json_schema.dart';
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
import 'base/file_system.dart';
......@@ -46,7 +45,7 @@ class AssetBundle {
for (String asset in assets) {
if (asset == '')
continue;
final String assetPath = path.join(projectRoot, asset);
final String assetPath = fs.path.join(projectRoot, asset);
final String archivePath = asset;
entries[archivePath] = new DevFSFileContent(fs.file(assetPath));
}
......@@ -74,7 +73,7 @@ class AssetBundle {
bool reportLicensedPackages: false
}) async {
workingDirPath ??= getAssetBuildDirectory();
packagesPath ??= path.absolute(PackageMap.globalPackagesPath);
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
Object manifest;
try {
manifest = _loadFlutterManifest(manifestPath);
......@@ -95,7 +94,7 @@ class AssetBundle {
}
Map<String, dynamic> manifestDescriptor = manifest;
manifestDescriptor = manifestDescriptor['flutter'] ?? <String, dynamic>{};
String assetBasePath = path.dirname(path.absolute(manifestPath));
String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath));
_lastBuildTimestamp = new DateTime.now();
......@@ -193,7 +192,7 @@ class _Asset {
}
Map<String, dynamic> _readMaterialFontsManifest() {
String fontsPath = path.join(path.absolute(Cache.flutterRoot),
String fontsPath = fs.path.join(fs.path.absolute(Cache.flutterRoot),
'packages', 'flutter_tools', 'schema', 'material_fonts.yaml');
return loadYaml(fs.file(fontsPath).readAsStringSync());
......@@ -212,8 +211,8 @@ List<_Asset> _getMaterialAssets(String fontSet) {
for (Map<String, dynamic> font in family['fonts']) {
String assetKey = font['asset'];
result.add(new _Asset(
base: path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
source: path.basename(assetKey),
base: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
source: fs.path.basename(assetKey),
relativePath: assetKey
));
}
......@@ -338,7 +337,7 @@ Map<_Asset, List<_Asset>> _parseAssets(
return result;
excludeDirs = excludeDirs.map(
(String exclude) => path.absolute(exclude) + fs.path.separator).toList();
(String exclude) => fs.path.absolute(exclude) + fs.path.separator).toList();
if (manifestDescriptor.containsKey('assets')) {
for (String asset in manifestDescriptor['assets']) {
......@@ -354,8 +353,8 @@ Map<_Asset, List<_Asset>> _parseAssets(
// Find asset variants
String assetPath = baseAsset.assetFile.path;
String assetFilename = path.basename(assetPath);
Directory assetDir = fs.directory(path.dirname(assetPath));
String assetFilename = fs.path.basename(assetPath);
Directory assetDir = fs.directory(fs.path.dirname(assetPath));
List<FileSystemEntity> files = assetDir.listSync(recursive: true);
......@@ -367,11 +366,11 @@ Map<_Asset, List<_Asset>> _parseAssets(
if (excludeDirs.any((String exclude) => entity.path.startsWith(exclude)))
continue;
if (path.basename(entity.path) == assetFilename && entity.path != assetPath) {
String key = path.relative(entity.path, from: baseAsset.base);
if (fs.path.basename(entity.path) == assetFilename && entity.path != assetPath) {
String key = fs.path.relative(entity.path, from: baseAsset.base);
String assetEntry;
if (baseAsset.symbolicPrefix != null)
assetEntry = path.join(baseAsset.symbolicPrefix, key);
assetEntry = fs.path.join(baseAsset.symbolicPrefix, key);
variants.add(new _Asset(base: baseAsset.base, assetEntry: assetEntry, relativePath: key));
}
}
......@@ -407,7 +406,7 @@ _Asset _resolveAsset(
String assetBase,
String asset
) {
if (asset.startsWith('packages/') && !fs.isFileSync(path.join(assetBase, asset))) {
if (asset.startsWith('packages/') && !fs.isFileSync(fs.path.join(assetBase, asset))) {
// Convert packages/flutter_gallery_assets/clouds-0.png to clouds-0.png.
String packageKey = asset.substring(9);
String relativeAsset = asset;
......@@ -436,9 +435,9 @@ dynamic _loadFlutterManifest(String manifestPath) {
}
Future<int> _validateFlutterManifest(Object manifest) async {
String schemaPath = path.join(path.absolute(Cache.flutterRoot),
String schemaPath = fs.path.join(fs.path.absolute(Cache.flutterRoot),
'packages', 'flutter_tools', 'schema', 'pubspec_yaml.json');
Schema schema = await Schema.createSchemaFromUrl(path.toUri(schemaPath).toString());
Schema schema = await Schema.createSchemaFromUrl(fs.path.toUri(schemaPath).toString());
Validator validator = new Validator(schema);
if (validator.validate(manifest)) {
......
......@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'file_system.dart';
import 'platform.dart';
const int kDefaultObservatoryPort = 8100;
......@@ -16,7 +15,7 @@ String get homeDirPath {
? platform.environment['USERPROFILE']
: platform.environment['HOME'];
if (_homeDirPath != null)
_homeDirPath = path.absolute(_homeDirPath);
_homeDirPath = fs.path.absolute(_homeDirPath);
}
return _homeDirPath;
}
......
......@@ -4,15 +4,13 @@
import 'dart:convert';
import 'package:path/path.dart' as path;
import 'context.dart';
import 'file_system.dart';
import 'platform.dart';
class Config {
Config([File configFile]) {
_configFile = configFile ?? fs.file(path.join(_userHomeDir(), '.flutter_settings'));
_configFile = configFile ?? fs.file(fs.path.join(_userHomeDir(), '.flutter_settings'));
if (_configFile.existsSync())
_values = JSON.decode(_configFile.readAsStringSync());
}
......
......@@ -6,7 +6,7 @@ import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:file/memory.dart';
import 'package:file/record_replay.dart';
import 'package:path/path.dart' as path;
import 'common.dart' show throwToolExit;
import 'context.dart';
......@@ -56,7 +56,7 @@ void enableReplayFileSystem(String location) {
/// Create the ancestor directories of a file path if they do not already exist.
void ensureDirectoryExists(String filePath) {
String dirPath = path.dirname(filePath);
String dirPath = fs.path.dirname(filePath);
if (fs.isDirectorySync(dirPath))
return;
try {
......@@ -77,7 +77,7 @@ void copyDirectorySync(Directory srcDir, Directory destDir) {
destDir.createSync(recursive: true);
srcDir.listSync().forEach((FileSystemEntity entity) {
String newPath = path.join(destDir.path, path.basename(entity.path));
String newPath = fs.path.join(destDir.path, fs.path.basename(entity.path));
if (entity is File) {
File newFile = destDir.fileSystem.file(newPath);
newFile.writeAsBytesSync(entity.readAsBytesSync());
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:archive/archive.dart';
import 'package:path/path.dart' as path;
import 'context.dart';
import 'file_system.dart';
......@@ -106,7 +105,7 @@ class _WindowsUtils extends OperatingSystemUtils {
if (!archiveFile.isFile || archiveFile.name.endsWith('/'))
continue;
File destFile = fs.file(path.join(targetDirectory.path, archiveFile.name));
File destFile = fs.file(fs.path.join(targetDirectory.path, archiveFile.name));
if (!destFile.parent.existsSync())
destFile.parent.createSync(recursive: true);
destFile.writeAsBytesSync(archiveFile.content);
......@@ -162,9 +161,9 @@ String findProjectRoot([String directory]) {
const String kProjectRootSentinel = 'pubspec.yaml';
directory ??= fs.currentDirectory.path;
while (true) {
if (fs.isFileSync(path.join(directory, kProjectRootSentinel)))
if (fs.isFileSync(fs.path.join(directory, kProjectRootSentinel)))
return directory;
String parent = path.dirname(directory);
String parent = fs.path.dirname(directory);
if (directory == parent) return null;
directory = parent;
}
......
......@@ -7,7 +7,6 @@ import 'dart:convert';
import 'dart:math' show Random;
import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path;
import 'file_system.dart';
import 'platform.dart';
......@@ -66,7 +65,7 @@ File getUniqueFile(Directory dir, String baseName, String ext) {
while (true) {
String name = '${baseName}_${i.toString().padLeft(2, '0')}.$ext';
File file = fs.file(path.join(dir.path, name));
File file = fs.file(fs.path.join(dir.path, name));
if (!file.existsSync())
return file;
i++;
......
......@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/platform.dart';
import 'base/utils.dart';
import 'globals.dart';
......@@ -129,7 +128,7 @@ String getBuildDirectory() {
return 'build';
String buildDir = config.getValue('build-dir') ?? 'build';
if (path.isAbsolute(buildDir)) {
if (fs.path.isAbsolute(buildDir)) {
throw new Exception(
'build-dir config setting in ${config.configPath} must be relative');
}
......@@ -144,15 +143,15 @@ String getAndroidBuildDirectory() {
/// Returns the AOT build output directory.
String getAotBuildDirectory() {
return path.join(getBuildDirectory(), 'aot');
return fs.path.join(getBuildDirectory(), 'aot');
}
/// Returns the asset build output directory.
String getAssetBuildDirectory() {
return path.join(getBuildDirectory(), 'flx');
return fs.path.join(getBuildDirectory(), 'flx');
}
/// Returns the iOS build output directory.
String getIosBuildDirectory() {
return path.join(getBuildDirectory(), 'ios');
return fs.path.join(getBuildDirectory(), 'ios');
}
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/logger.dart';
......@@ -52,7 +50,7 @@ class Cache {
if (!_lockEnabled)
return null;
assert(_lock == null);
_lock = fs.file(path.join(flutterRoot, 'bin', 'cache', 'lockfile')).openSync(mode: FileMode.WRITE);
_lock = fs.file(fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile')).openSync(mode: FileMode.WRITE);
bool locked = false;
bool printed = false;
while (!locked) {
......@@ -91,7 +89,7 @@ class Cache {
static String get engineRevision {
if (_engineRevision == null) {
File revisionFile = fs.file(path.join(flutterRoot, 'bin', 'internal', 'engine.version'));
File revisionFile = fs.file(fs.path.join(flutterRoot, 'bin', 'internal', 'engine.version'));
if (revisionFile.existsSync())
_engineRevision = revisionFile.readAsStringSync().trim();
}
......@@ -103,14 +101,14 @@ class Cache {
/// Return the top-level directory in the cache; this is `bin/cache`.
Directory getRoot() {
if (_rootOverride != null)
return fs.directory(path.join(_rootOverride.path, 'bin', 'cache'));
return fs.directory(fs.path.join(_rootOverride.path, 'bin', 'cache'));
else
return fs.directory(path.join(flutterRoot, 'bin', 'cache'));
return fs.directory(fs.path.join(flutterRoot, 'bin', 'cache'));
}
/// Return a directory in the cache dir. For `pkg`, this will return `bin/cache/pkg`.
Directory getCacheDir(String name) {
Directory dir = fs.directory(path.join(getRoot().path, name));
Directory dir = fs.directory(fs.path.join(getRoot().path, name));
if (!dir.existsSync())
dir.createSync(recursive: true);
return dir;
......@@ -122,11 +120,11 @@ class Cache {
/// Get a named directory from with the cache's artifact directory; for example,
/// `material_fonts` would return `bin/cache/artifacts/material_fonts`.
Directory getArtifactDirectory(String name) {
return fs.directory(path.join(getCacheArtifacts().path, name));
return fs.directory(fs.path.join(getCacheArtifacts().path, name));
}
String getVersionFor(String artifactName) {
File versionFile = fs.file(path.join(_rootOverride?.path ?? flutterRoot, 'bin', 'internal', '$artifactName.version'));
File versionFile = fs.file(fs.path.join(_rootOverride?.path ?? flutterRoot, 'bin', 'internal', '$artifactName.version'));
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
}
......@@ -140,7 +138,7 @@ class Cache {
}
File getStampFileFor(String artifactName) {
return fs.file(path.join(getRoot().path, '$artifactName.stamp'));
return fs.file(fs.path.join(getRoot().path, '$artifactName.stamp'));
}
bool isUpToDate() {
......@@ -156,11 +154,11 @@ class Cache {
Uri url = Uri.parse(urlStr);
Directory thirdPartyDir = getArtifactDirectory('third_party');
Directory serviceDir = fs.directory(path.join(thirdPartyDir.path, serviceName));
Directory serviceDir = fs.directory(fs.path.join(thirdPartyDir.path, serviceName));
if (!serviceDir.existsSync())
serviceDir.createSync(recursive: true);
File cachedFile = fs.file(path.join(serviceDir.path, url.pathSegments.last));
File cachedFile = fs.file(fs.path.join(serviceDir.path, url.pathSegments.last));
if (!cachedFile.existsSync()) {
try {
await _downloadFileToCache(url, cachedFile, unzip);
......@@ -197,7 +195,7 @@ class Cache {
if (location is Directory && !location.existsSync())
location.createSync(recursive: true);
File tempFile = fs.file(path.join(fs.systemTempDirectory.path, '${url.toString().hashCode}.zip'));
File tempFile = fs.file(fs.path.join(fs.systemTempDirectory.path, '${url.toString().hashCode}.zip'));
tempFile.writeAsBytesSync(fileBytes, flush: true);
os.unzip(tempFile, location);
tempFile.deleteSync();
......@@ -311,14 +309,14 @@ class FlutterEngine {
bool isUpToDate() {
Directory pkgDir = cache.getCacheDir('pkg');
for (String pkgName in _getPackageDirs()) {
String pkgPath = path.join(pkgDir.path, pkgName);
String pkgPath = fs.path.join(pkgDir.path, pkgName);
if (!fs.directory(pkgPath).existsSync())
return false;
}
Directory engineDir = cache.getArtifactDirectory(kName);
for (List<String> toolsDir in _getBinaryDirs()) {
Directory dir = fs.directory(path.join(engineDir.path, toolsDir[0]));
Directory dir = fs.directory(fs.path.join(engineDir.path, toolsDir[0]));
if (!dir.existsSync())
return false;
}
......@@ -332,7 +330,7 @@ class FlutterEngine {
Directory pkgDir = cache.getCacheDir('pkg');
for (String pkgName in _getPackageDirs()) {
String pkgPath = path.join(pkgDir.path, pkgName);
String pkgPath = fs.path.join(pkgDir.path, pkgName);
Directory dir = fs.directory(pkgPath);
if (dir.existsSync())
dir.deleteSync(recursive: true);
......@@ -346,14 +344,14 @@ class FlutterEngine {
for (List<String> toolsDir in _getBinaryDirs()) {
String cacheDir = toolsDir[0];
String urlPath = toolsDir[1];
Directory dir = fs.directory(path.join(engineDir.path, cacheDir));
Directory dir = fs.directory(fs.path.join(engineDir.path, cacheDir));
await _downloadItem('Downloading $cacheDir tools...', url + urlPath, dir);
_makeFilesExecutable(dir);
File frameworkZip = fs.file(path.join(dir.path, 'Flutter.framework.zip'));
File frameworkZip = fs.file(fs.path.join(dir.path, 'Flutter.framework.zip'));
if (frameworkZip.existsSync()) {
Directory framework = fs.directory(path.join(dir.path, 'Flutter.framework'));
Directory framework = fs.directory(fs.path.join(dir.path, 'Flutter.framework'));
framework.createSync();
os.unzip(frameworkZip, framework);
}
......@@ -365,7 +363,7 @@ class FlutterEngine {
void _makeFilesExecutable(Directory dir) {
for (FileSystemEntity entity in dir.listSync()) {
if (entity is File) {
String name = path.basename(entity.path);
String name = fs.path.basename(entity.path);
if (name == 'sky_snapshot' || name == 'sky_shell')
os.makeExecutable(entity);
}
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/utils.dart';
......@@ -56,11 +55,11 @@ abstract class AnalyzeBase {
/// If [fileList] is empty, then return `true` if the current directory resides inside the Flutter repository.
bool inRepo(List<String> fileList) {
if (fileList == null || fileList.isEmpty)
fileList = <String>[path.current];
String root = path.normalize(path.absolute(Cache.flutterRoot));
fileList = <String>[fs.path.current];
String root = fs.path.normalize(fs.path.absolute(Cache.flutterRoot));
String prefix = root + fs.path.separator;
for (String file in fileList) {
file = path.normalize(path.absolute(file));
file = fs.path.normalize(fs.path.absolute(file));
if (file == root || file.startsWith(prefix))
return true;
}
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
......@@ -41,7 +40,7 @@ class AnalyzeContinuously extends AnalyzeBase {
analysisTarget = 'Flutter repository';
printTrace('Analyzing Flutter repository:');
for (String projectPath in directories)
printTrace(' ${path.relative(projectPath)}');
printTrace(' ${fs.path.relative(projectPath)}');
} else {
directories = <String>[fs.currentDirectory.path];
analysisTarget = fs.currentDirectory.path;
......@@ -157,9 +156,9 @@ class AnalysisServer {
int _id = 0;
Future<Null> start() async {
String snapshot = path.join(sdk, 'bin/snapshots/analysis_server.dart.snapshot');
String snapshot = fs.path.join(sdk, 'bin/snapshots/analysis_server.dart.snapshot');
List<String> command = <String>[
path.join(dartSdkPath, 'bin', 'dart'),
fs.path.join(dartSdkPath, 'bin', 'dart'),
snapshot,
'--sdk',
sdk,
......@@ -309,7 +308,7 @@ class AnalysisError implements Comparable<AnalysisError> {
@override
String toString() {
String relativePath = path.relative(file);
String relativePath = fs.path.relative(file);
return '${severity.toLowerCase().padLeft(7)}$message$relativePath:$startLine:$startColumn';
}
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:collection';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart' as yaml;
import '../base/common.dart';
......@@ -34,12 +33,12 @@ class AnalyzeOnce extends AnalyzeBase {
List<File> dartFiles = <File>[];
for (String file in argResults.rest.toList()) {
file = path.normalize(path.absolute(file));
String root = path.rootPrefix(file);
file = fs.path.normalize(fs.path.absolute(file));
String root = fs.path.rootPrefix(file);
dartFiles.add(fs.file(file));
while (file != root) {
file = path.dirname(file);
if (fs.isFileSync(path.join(file, 'pubspec.yaml'))) {
file = fs.path.dirname(file);
if (fs.isFileSync(fs.path.join(file, 'pubspec.yaml'))) {
pubSpecDirectories.add(fs.directory(file));
break;
}
......@@ -83,7 +82,7 @@ class AnalyzeOnce extends AnalyzeBase {
// determine what all the various .packages files depend on
PackageDependencyTracker dependencies = new PackageDependencyTracker();
for (Directory directory in pubSpecDirectories) {
String pubSpecYamlPath = path.join(directory.path, 'pubspec.yaml');
String pubSpecYamlPath = fs.path.join(directory.path, 'pubspec.yaml');
File pubSpecYamlFile = fs.file(pubSpecYamlPath);
if (pubSpecYamlFile.existsSync()) {
// we are analyzing the actual canonical source for this package;
......@@ -91,10 +90,10 @@ class AnalyzeOnce extends AnalyzeBase {
// pointing elsewhere somehow.
yaml.YamlMap pubSpecYaml = yaml.loadYaml(fs.file(pubSpecYamlPath).readAsStringSync());
String packageName = pubSpecYaml['name'];
String packagePath = path.normalize(path.absolute(path.join(directory.path, 'lib')));
String packagePath = fs.path.normalize(fs.path.absolute(fs.path.join(directory.path, 'lib')));
dependencies.addCanonicalCase(packageName, packagePath, pubSpecYamlPath);
}
String dotPackagesPath = path.join(directory.path, '.packages');
String dotPackagesPath = fs.path.join(directory.path, '.packages');
File dotPackages = fs.file(dotPackagesPath);
if (dotPackages.existsSync()) {
// this directory has opinions about what we should be using
......@@ -106,12 +105,12 @@ class AnalyzeOnce extends AnalyzeBase {
int colon = line.indexOf(':');
if (colon > 0) {
String packageName = line.substring(0, colon);
String packagePath = path.fromUri(line.substring(colon+1));
// Ensure that we only add the `analyzer` package defined in the vended SDK (and referred to with a local path directive).
String packagePath = fs.path.fromUri(line.substring(colon+1));
// Ensure that we only add the `analyzer` package defined in the vended SDK (and referred to with a local fs.path. directive).
// Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored since they would produce
// spurious conflicts.
if (packageName != 'analyzer' || packagePath.startsWith('..'))
dependencies.add(packageName, path.normalize(path.absolute(directory.path, packagePath)), dotPackagesPath);
dependencies.add(packageName, fs.path.normalize(fs.path.absolute(directory.path, packagePath)), dotPackagesPath);
}
});
}
......@@ -138,7 +137,7 @@ class AnalyzeOnce extends AnalyzeBase {
if (argResults['preamble']) {
if (dartFiles.length == 1) {
logger.printStatus('Analyzing ${path.relative(dartFiles.first.path)}...');
logger.printStatus('Analyzing ${fs.path.relative(dartFiles.first.path)}...');
} else {
logger.printStatus('Analyzing ${dartFiles.length} files...');
}
......@@ -147,8 +146,8 @@ class AnalyzeOnce extends AnalyzeBase {
options.dartSdkPath = argResults['dart-sdk'];
options.packageMap = packages;
options.analysisOptionsFile = flutterRepo
? path.join(Cache.flutterRoot, '.analysis_options_repo')
: path.join(Cache.flutterRoot, 'packages', 'flutter', 'lib', 'analysis_options_user.yaml');
? fs.path.join(Cache.flutterRoot, '.analysis_options_repo')
: fs.path.join(Cache.flutterRoot, 'packages', 'flutter', 'lib', 'analysis_options_user.yaml');
AnalysisDriver analyzer = new AnalysisDriver(options);
// TODO(pq): consider error handling
......@@ -200,8 +199,8 @@ class AnalyzeOnce extends AnalyzeBase {
List<String> flutterRootComponents;
bool isFlutterLibrary(String filename) {
flutterRootComponents ??= path.normalize(path.absolute(Cache.flutterRoot)).split(path.separator);
List<String> filenameComponents = path.normalize(path.absolute(filename)).split(path.separator);
flutterRootComponents ??= fs.path.normalize(fs.path.absolute(Cache.flutterRoot)).split(fs.path.separator);
List<String> filenameComponents = fs.path.normalize(fs.path.absolute(filename)).split(fs.path.separator);
if (filenameComponents.length < flutterRootComponents.length + 4) // the 4: 'packages', package_name, 'lib', file_name
return false;
for (int index = 0; index < flutterRootComponents.length; index += 1) {
......@@ -219,14 +218,14 @@ class AnalyzeOnce extends AnalyzeBase {
List<File> _collectDartFiles(Directory dir, List<File> collected) {
// Bail out in case of a .dartignore.
if (fs.isFileSync(path.join(dir.path, '.dartignore')))
if (fs.isFileSync(fs.path.join(dir.path, '.dartignore')))
return collected;
for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
if (isDartFile(entity))
collected.add(entity);
if (entity is Directory) {
String name = path.basename(entity.path);
String name = fs.path.basename(entity.path);
if (!name.startsWith('.') && name != 'packages')
_collectDartFiles(entity, collected);
}
......@@ -251,11 +250,11 @@ class PackageDependency {
}
bool get hasConflict => values.length > 1;
bool get hasConflictAffectingFlutterRepo {
assert(path.isAbsolute(Cache.flutterRoot));
assert(fs.path.isAbsolute(Cache.flutterRoot));
for (List<String> targetSources in values.values) {
for (String source in targetSources) {
assert(path.isAbsolute(source));
if (path.isWithin(Cache.flutterRoot, source))
assert(fs.path.isAbsolute(source));
if (fs.path.isWithin(Cache.flutterRoot, source))
return true;
}
}
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
......@@ -51,7 +49,7 @@ class BuildAotCommand extends BuildSubCommand {
if (platform == null)
throwToolExit('Unknown platform: $targetPlatform');
String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, getBuildMode()).path);
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(platform, getBuildMode()).path);
Status status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...',
expectSlowOperation: true);
String outputPath = await buildAotSnapshot(
......@@ -71,7 +69,7 @@ class BuildAotCommand extends BuildSubCommand {
}
String _getSdkExtensionPath(PackageMap packageMap, String package) {
return path.dirname(packageMap.map[package].toFilePath());
return fs.path.dirname(packageMap.map[package].toFilePath());
}
/// Build an AOT snapshot. Return `null` (and log to `printError`) if the method
......@@ -122,15 +120,15 @@ Future<String> _buildAotSnapshot(
String engineSrc = tools.engineSrcPath;
String genSnapshotExecutable = 'gen_snapshot';
if (engineSrc != null) {
entryPointsDir = path.join(engineSrc, 'flutter', 'runtime');
dartEntryPointsDir = path.join(engineSrc, 'dart', 'runtime', 'bin');
snapshotterDir = path.join(engineSrc, 'flutter', 'lib', 'snapshot');
entryPointsDir = fs.path.join(engineSrc, 'flutter', 'runtime');
dartEntryPointsDir = fs.path.join(engineSrc, 'dart', 'runtime', 'bin');
snapshotterDir = fs.path.join(engineSrc, 'flutter', 'lib', 'snapshot');
String engineOut = tools.getEngineArtifactsDirectory(platform, buildMode).path;
if (platform == TargetPlatform.ios) {
genSnapshot = path.join(engineOut, 'clang_x64', genSnapshotExecutable);
genSnapshot = fs.path.join(engineOut, 'clang_x64', genSnapshotExecutable);
} else {
String host32BitToolchain = getCurrentHostPlatform() == HostPlatform.darwin_x64 ? 'clang_i386' : 'clang_x86';
genSnapshot = path.join(engineOut, host32BitToolchain, genSnapshotExecutable);
genSnapshot = fs.path.join(engineOut, host32BitToolchain, genSnapshotExecutable);
}
} else {
String artifactsDir = tools.getEngineArtifactsDirectory(platform, buildMode).path;
......@@ -138,22 +136,22 @@ Future<String> _buildAotSnapshot(
dartEntryPointsDir = entryPointsDir;
snapshotterDir = entryPointsDir;
if (platform == TargetPlatform.ios) {
genSnapshot = path.join(artifactsDir, genSnapshotExecutable);
genSnapshot = fs.path.join(artifactsDir, genSnapshotExecutable);
} else {
String hostToolsDir = path.join(artifactsDir, getNameForHostPlatform(getCurrentHostPlatform()));
genSnapshot = path.join(hostToolsDir, genSnapshotExecutable);
String hostToolsDir = fs.path.join(artifactsDir, getNameForHostPlatform(getCurrentHostPlatform()));
genSnapshot = fs.path.join(hostToolsDir, genSnapshotExecutable);
}
}
Directory outputDir = fs.directory(outputPath);
outputDir.createSync(recursive: true);
String vmSnapshotData = path.join(outputDir.path, 'vm_snapshot_data');
String vmSnapshotInstructions = path.join(outputDir.path, 'vm_snapshot_instr');
String isolateSnapshotData = path.join(outputDir.path, 'isolate_snapshot_data');
String isolateSnapshotInstructions = path.join(outputDir.path, 'isolate_snapshot_instr');
String vmSnapshotData = fs.path.join(outputDir.path, 'vm_snapshot_data');
String vmSnapshotInstructions = fs.path.join(outputDir.path, 'vm_snapshot_instr');
String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data');
String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr');
String vmEntryPoints = path.join(entryPointsDir, 'dart_vm_entry_points.txt');
String ioEntryPoints = path.join(dartEntryPointsDir, 'dart_io_entries.txt');
String vmEntryPoints = fs.path.join(entryPointsDir, 'dart_vm_entry_points.txt');
String ioEntryPoints = fs.path.join(dartEntryPointsDir, 'dart_io_entries.txt');
PackageMap packageMap = new PackageMap(PackageMap.globalPackagesPath);
String packageMapError = packageMap.checkValid();
......@@ -163,9 +161,9 @@ Future<String> _buildAotSnapshot(
}
String skyEnginePkg = _getSdkExtensionPath(packageMap, 'sky_engine');
String uiPath = path.join(skyEnginePkg, 'dart_ui', 'ui.dart');
String jniPath = path.join(skyEnginePkg, 'dart_jni', 'jni.dart');
String vmServicePath = path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
String uiPath = fs.path.join(skyEnginePkg, 'dart_ui', 'ui.dart');
String jniPath = fs.path.join(skyEnginePkg, 'dart_jni', 'jni.dart');
String vmServicePath = fs.path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
List<String> filePaths = <String>[
vmEntryPoints,
......@@ -186,14 +184,14 @@ Future<String> _buildAotSnapshot(
case TargetPlatform.android_arm:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
vmEntryPointsAndroid = path.join(entryPointsDir, 'dart_vm_entry_points_android.txt');
vmEntryPointsAndroid = fs.path.join(entryPointsDir, 'dart_vm_entry_points_android.txt');
filePaths.addAll(<String>[
vmEntryPointsAndroid,
]);
break;
case TargetPlatform.ios:
snapshotDartIOS = path.join(snapshotterDir, 'snapshot.dart');
assembly = path.join(outputDir.path, 'snapshot_assembly.S');
snapshotDartIOS = fs.path.join(snapshotterDir, 'snapshot.dart');
assembly = fs.path.join(outputDir.path, 'snapshot_assembly.S');
filePaths.addAll(<String>[
snapshotDartIOS,
]);
......@@ -276,23 +274,23 @@ Future<String> _buildAotSnapshot(
String kVmSnapshotData = 'kDartVmSnapshotData';
String kIsolateSnapshotData = 'kDartIsolateSnapshotData';
String kVmSnapshotDataC = path.join(outputDir.path, '$kVmSnapshotData.c');
String kIsolateSnapshotDataC = path.join(outputDir.path, '$kIsolateSnapshotData.c');
String kVmSnapshotDataO = path.join(outputDir.path, '$kVmSnapshotData.o');
String kIsolateSnapshotDataO = path.join(outputDir.path, '$kIsolateSnapshotData.o');
String assemblyO = path.join(outputDir.path, 'snapshot_assembly.o');
String kVmSnapshotDataC = fs.path.join(outputDir.path, '$kVmSnapshotData.c');
String kIsolateSnapshotDataC = fs.path.join(outputDir.path, '$kIsolateSnapshotData.c');
String kVmSnapshotDataO = fs.path.join(outputDir.path, '$kVmSnapshotData.o');
String kIsolateSnapshotDataO = fs.path.join(outputDir.path, '$kIsolateSnapshotData.o');
String assemblyO = fs.path.join(outputDir.path, 'snapshot_assembly.o');
List<String> commonBuildOptions = <String>['-arch', 'arm64', '-miphoneos-version-min=8.0'];
if (interpreter) {
runCheckedSync(<String>['mv', vmSnapshotData, path.join(outputDir.path, kVmSnapshotData)]);
runCheckedSync(<String>['mv', isolateSnapshotData, path.join(outputDir.path, kIsolateSnapshotData)]);
runCheckedSync(<String>['mv', vmSnapshotData, fs.path.join(outputDir.path, kVmSnapshotData)]);
runCheckedSync(<String>['mv', isolateSnapshotData, fs.path.join(outputDir.path, kIsolateSnapshotData)]);
runCheckedSync(<String>[
'xxd', '--include', kVmSnapshotData, path.basename(kVmSnapshotDataC)
'xxd', '--include', kVmSnapshotData, fs.path.basename(kVmSnapshotDataC)
], workingDirectory: outputDir.path);
runCheckedSync(<String>[
'xxd', '--include', kIsolateSnapshotData, path.basename(kIsolateSnapshotDataC)
'xxd', '--include', kIsolateSnapshotData, fs.path.basename(kIsolateSnapshotDataC)
], workingDirectory: outputDir.path);
runCheckedSync(<String>['xcrun', 'cc']
......@@ -307,7 +305,7 @@ Future<String> _buildAotSnapshot(
..addAll(<String>['-c', assembly, '-o', assemblyO]));
}
String appSo = path.join(outputDir.path, 'app.dylib');
String appSo = fs.path.join(outputDir.path, 'app.dylib');
List<String> linkCommand = <String>['xcrun', 'clang']
..addAll(commonBuildOptions)
......
......@@ -5,8 +5,6 @@
import 'dart:async';
import 'dart:convert' show JSON;
import 'package:path/path.dart' as path;
import '../android/android_sdk.dart';
import '../android/gradle.dart';
import '../base/common.dart';
......@@ -39,8 +37,8 @@ const String _kDebugKeystoreKeyAlias = "chromiumdebugkey";
// Password for the Chromium debug keystore
const String _kDebugKeystorePassword = "chromium";
// Default APK output path.
String get _defaultOutputPath => path.join(getAndroidBuildDirectory(), 'app.apk');
// Default APK output fs.path.
String get _defaultOutputPath => fs.path.join(getAndroidBuildDirectory(), 'app.apk');
/// Copies files into a new directory structure.
class _AssetBuilder {
......@@ -54,7 +52,7 @@ class _AssetBuilder {
}
void add(File asset, String relativePath) {
String destPath = path.join(_assetDir.path, relativePath);
String destPath = fs.path.join(_assetDir.path, relativePath);
ensureDirectoryExists(destPath);
asset.copySync(destPath);
}
......@@ -176,7 +174,7 @@ class BuildApkCommand extends BuildSubCommand {
help: 'Android manifest XML file.');
argParser.addOption('resources',
abbr: 'r',
help: 'Resources directory path.');
help: 'Resources directory fs.path.');
argParser.addOption('output-file',
abbr: 'o',
defaultsTo: _defaultOutputPath,
......@@ -301,12 +299,12 @@ Future<_ApkComponents> _findApkComponents(
} else {
Directory artifacts = tools.getEngineArtifactsDirectory(platform, buildMode);
components.icuData = fs.file(path.join(artifacts.path, 'icudtl.dat'));
components.icuData = fs.file(fs.path.join(artifacts.path, 'icudtl.dat'));
components.jars = <File>[
fs.file(path.join(artifacts.path, 'classes.dex.jar'))
fs.file(fs.path.join(artifacts.path, 'classes.dex.jar'))
];
components.libSkyShell = fs.file(path.join(artifacts.path, 'libsky_shell.so'));
components.debugKeystore = fs.file(path.join(artifacts.path, 'chromium-debug.keystore'));
components.libSkyShell = fs.file(fs.path.join(artifacts.path, 'libsky_shell.so'));
components.debugKeystore = fs.file(fs.path.join(artifacts.path, 'chromium-debug.keystore'));
}
await parseServiceConfigs(components.services, jars: components.jars);
......@@ -465,7 +463,7 @@ bool _needsRebuild(
if (!fs.isFileSync('$apkPath.sha1'))
return true;
String lastBuildType = _readBuildMeta(path.dirname(apkPath))['targetBuildType'];
String lastBuildType = _readBuildMeta(fs.path.dirname(apkPath))['targetBuildType'];
String targetBuildType = _getTargetBuildTypeToken(platform, buildMode, fs.file(apkPath));
if (lastBuildType != targetBuildType)
return true;
......@@ -534,7 +532,7 @@ Future<Null> buildAndroid(
if (components == null)
throwToolExit('Failure building APK: unable to find components.');
String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, buildMode).path);
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(platform, buildMode).path);
Status status = logger.startProgress('Building APK in ${getModeName(buildMode)} mode ($typeName)...',
expectSlowOperation: true);
......@@ -567,7 +565,7 @@ Future<Null> buildAndroid(
if (!fs.isDirectorySync(aotPath))
throwToolExit('AOT snapshot does not exist: $aotPath');
for (String aotFilename in kAotSnapshotFiles) {
String aotFilePath = path.join(aotPath, aotFilename);
String aotFilePath = fs.path.join(aotPath, aotFilename);
if (!fs.isFileSync(aotFilePath))
throwToolExit('Missing AOT snapshot file: $aotFilePath');
components.extraFiles['assets/$aotFilename'] = fs.file(aotFilePath);
......@@ -584,7 +582,7 @@ Future<Null> buildAndroid(
printTrace('Built $outputFile (${getSizeAsMB(apkFile.lengthSync())}).');
_writeBuildMetaEntry(
path.dirname(outputFile),
fs.path.dirname(outputFile),
'targetBuildType',
_getTargetBuildTypeToken(platform, buildMode, fs.file(outputFile))
);
......@@ -640,7 +638,7 @@ Future<Null> buildApk(
}
Map<String, dynamic> _readBuildMeta(String buildDirectoryPath) {
File buildMetaFile = fs.file(path.join(buildDirectoryPath, 'build_meta.json'));
File buildMetaFile = fs.file(fs.path.join(buildDirectoryPath, 'build_meta.json'));
if (buildMetaFile.existsSync())
return JSON.decode(buildMetaFile.readAsStringSync());
return <String, dynamic>{};
......@@ -649,7 +647,7 @@ Map<String, dynamic> _readBuildMeta(String buildDirectoryPath) {
void _writeBuildMetaEntry(String buildDirectoryPath, String key, dynamic value) {
Map<String, dynamic> meta = _readBuildMeta(buildDirectoryPath);
meta[key] = value;
File buildMetaFile = fs.file(path.join(buildDirectoryPath, 'build_meta.json'));
File buildMetaFile = fs.file(fs.path.join(buildDirectoryPath, 'build_meta.json'));
buildMetaFile.writeAsStringSync(toPrettyJson(meta));
}
......
......@@ -4,10 +4,9 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../application_package.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/utils.dart';
import '../build_info.dart';
......@@ -64,7 +63,7 @@ class BuildIOSCommand extends BuildSubCommand {
String logTarget = forSimulator ? 'simulator' : 'device';
String typeName = path.basename(tools.getEngineArtifactsDirectory(TargetPlatform.ios, getBuildMode()).path);
String typeName = fs.path.basename(tools.getEngineArtifactsDirectory(TargetPlatform.ios, getBuildMode()).path);
Status status = logger.startProgress('Building $app for $logTarget ($typeName)...',
expectSlowOperation: true);
XcodeBuildResult result = await buildXcodeProject(
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../android/android.dart' as android;
import '../base/common.dart';
import '../base/file_system.dart';
......@@ -68,21 +66,21 @@ class CreateCommand extends FlutterCommand {
await Cache.instance.updateAll();
String flutterRoot = path.absolute(Cache.flutterRoot);
String flutterRoot = fs.path.absolute(Cache.flutterRoot);
String flutterPackagesDirectory = path.join(flutterRoot, 'packages');
String flutterPackagePath = path.join(flutterPackagesDirectory, 'flutter');
if (!fs.isFileSync(path.join(flutterPackagePath, 'pubspec.yaml')))
String flutterPackagesDirectory = fs.path.join(flutterRoot, 'packages');
String flutterPackagePath = fs.path.join(flutterPackagesDirectory, 'flutter');
if (!fs.isFileSync(fs.path.join(flutterPackagePath, 'pubspec.yaml')))
throwToolExit('Unable to find package:flutter in $flutterPackagePath', exitCode: 2);
String flutterDriverPackagePath = path.join(flutterRoot, 'packages', 'flutter_driver');
if (!fs.isFileSync(path.join(flutterDriverPackagePath, 'pubspec.yaml')))
String flutterDriverPackagePath = fs.path.join(flutterRoot, 'packages', 'flutter_driver');
if (!fs.isFileSync(fs.path.join(flutterDriverPackagePath, 'pubspec.yaml')))
throwToolExit('Unable to find package:flutter_driver in $flutterDriverPackagePath', exitCode: 2);
Directory projectDir = fs.directory(argResults.rest.first);
String dirPath = path.normalize(projectDir.absolute.path);
String relativePath = path.relative(dirPath);
String projectName = _normalizeProjectName(path.basename(dirPath));
String dirPath = fs.path.normalize(projectDir.absolute.path);
String relativePath = fs.path.relative(dirPath);
String projectName = _normalizeProjectName(fs.path.basename(dirPath));
String error =_validateProjectDir(dirPath, flutterRoot: flutterRoot);
if (error != null)
......@@ -141,10 +139,10 @@ Your main program file is lib/main.dart in the $relativePath directory.
String flutterPackagesDirectory, { bool renderDriverTest: false }) {
fs.directory(dirPath).createSync(recursive: true);
flutterPackagesDirectory = path.normalize(flutterPackagesDirectory);
flutterPackagesDirectory = fs.path.normalize(flutterPackagesDirectory);
flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
printStatus('Creating project ${path.relative(dirPath)}...');
printStatus('Creating project ${fs.path.relative(dirPath)}...');
Map<String, dynamic> templateContext = <String, dynamic>{
'projectName': projectName,
......@@ -168,7 +166,7 @@ Your main program file is lib/main.dart in the $relativePath directory.
if (renderDriverTest) {
Template driverTemplate = new Template.fromName('driver');
fileCount += driverTemplate.render(fs.directory(path.join(dirPath, 'test_driver')),
fileCount += driverTemplate.render(fs.directory(fs.path.join(dirPath, 'test_driver')),
templateContext, overwriteExisting: false);
}
......@@ -229,7 +227,7 @@ String _validateProjectName(String projectName) {
/// Return `null` if the project directory is legal. Return a validation message
/// if we should disallow the directory name.
String _validateProjectDir(String dirPath, { String flutterRoot }) {
if (path.isWithin(flutterRoot, dirPath)) {
if (fs.path.isWithin(flutterRoot, dirPath)) {
return "Cannot create a project within the Flutter SDK.\n"
"Target directory '$dirPath' is within the Flutter SDK at '$flutterRoot'.";
}
......@@ -251,9 +249,9 @@ String _validateProjectDir(String dirPath, { String flutterRoot }) {
}
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 (fs.isDirectorySync(path.join(from, result)))
String result = fs.path.relative(to, from: from);
// `fs.path.relative()` doesn't always return a correct result: dart-lang/path#12.
if (fs.isDirectorySync(fs.path.join(from, result)))
return result;
return to;
}
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../android/android_device.dart' show AndroidDevice;
import '../application_package.dart';
import '../base/file_system.dart';
......@@ -140,25 +138,25 @@ class DriveCommand extends RunCommandBase {
}
String _getTestFile() {
String appFile = path.normalize(targetFile);
String appFile = fs.path.normalize(targetFile);
// This command extends `flutter start` and therefore CWD == package dir
String packageDir = fs.currentDirectory.path;
// Make appFile path relative to package directory because we are looking
// for the corresponding test file relative to it.
if (!path.isRelative(appFile)) {
if (!path.isWithin(packageDir, appFile)) {
if (!fs.path.isRelative(appFile)) {
if (!fs.path.isWithin(packageDir, appFile)) {
printError(
'Application file $appFile is outside the package directory $packageDir'
);
return null;
}
appFile = path.relative(appFile, from: packageDir);
appFile = fs.path.relative(appFile, from: packageDir);
}
List<String> parts = path.split(appFile);
List<String> parts = fs.path.split(appFile);
if (parts.length < 2) {
printError(
......@@ -171,9 +169,9 @@ class DriveCommand extends RunCommandBase {
// Look for the test file inside `test_driver/` matching the sub-path, e.g.
// if the application is `lib/foo/bar.dart`, the test file is expected to
// be `test_driver/foo/bar_test.dart`.
String pathWithNoExtension = path.withoutExtension(path.joinAll(
String pathWithNoExtension = fs.path.withoutExtension(fs.path.joinAll(
<String>[packageDir, 'test_driver']..addAll(parts.skip(1))));
return '${pathWithNoExtension}_test${path.extension(appFile)}';
return '${pathWithNoExtension}_test${fs.path.extension(appFile)}';
}
}
......@@ -317,11 +315,11 @@ void restoreTestRunner() {
Future<Null> _runTests(List<String> testArgs, String observatoryUri) async {
printTrace('Running driver tests.');
PackageMap.globalPackagesPath = path.normalize(path.absolute(PackageMap.globalPackagesPath));
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
List<String> args = testArgs.toList()
..add('--packages=${PackageMap.globalPackagesPath}')
..add('-rexpanded');
String dartVmPath = path.join(dartSdkPath, 'bin', 'dart');
String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
int result = await runCommandAndStreamOutput(
<String>[dartVmPath]..addAll(args),
environment: <String, String>{ 'VM_SERVICE_URL': observatoryUri }
......
......@@ -4,9 +4,8 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/process.dart';
import '../cache.dart';
import '../runner/flutter_command.dart';
......@@ -37,7 +36,7 @@ class FormatCommand extends FlutterCommand {
);
}
String dartfmt = path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', 'dartfmt');
String dartfmt = fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', 'dartfmt');
List<String> cmd = <String>[dartfmt, '-w']..addAll(argResults.rest);
int result = await runCommandAndStreamOutput(cmd);
if (result != 0)
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
......@@ -139,6 +138,6 @@ class ScreenshotCommand extends FlutterCommand {
Future<Null> showOutputFileInfo(File outputFile) async {
int sizeKB = (await outputFile.length()) ~/ 1024;
printStatus('Screenshot written to ${path.relative(outputFile.path)} (${sizeKB}kB).');
printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).');
}
}
......@@ -4,7 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import 'package:test/src/executable.dart' as test; // ignore: implementation_imports
import '../base/common.dart';
......@@ -69,7 +68,7 @@ class TestCommand extends FlutterCommand {
return directory.listSync(recursive: true, followLinks: false)
.where((FileSystemEntity entity) => entity.path.endsWith('_test.dart') &&
fs.isFileSync(entity.path))
.map((FileSystemEntity entity) => path.absolute(entity.path));
.map((FileSystemEntity entity) => fs.path.absolute(entity.path));
}
Directory get _currentPackageTestDir {
......@@ -83,7 +82,7 @@ class TestCommand extends FlutterCommand {
try {
if (testDirectory != null) {
printTrace('switching to directory $testDirectory to run tests');
PackageMap.globalPackagesPath = path.normalize(path.absolute(PackageMap.globalPackagesPath));
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
fs.currentDirectory = testDirectory;
}
printTrace('running test package with arguments: $testArgs');
......@@ -139,7 +138,7 @@ class TestCommand extends FlutterCommand {
Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_tools');
try {
File sourceFile = coverageFile.copySync(path.join(tempDir.path, 'lcov.source.info'));
File sourceFile = coverageFile.copySync(fs.path.join(tempDir.path, 'lcov.source.info'));
ProcessResult result = processManager.runSync(<String>[
'lcov',
'--add-tracefile', baseCoverageData,
......@@ -173,7 +172,7 @@ class TestCommand extends FlutterCommand {
testArgs.add('--');
Directory testDir;
Iterable<String> files = argResults.rest.map((String testPath) => path.absolute(testPath)).toList();
Iterable<String> files = argResults.rest.map((String testPath) => fs.path.absolute(testPath)).toList();
if (argResults['start-paused']) {
if (files.length != 1)
throwToolExit('When using --start-paused, you must specify a single test file to run.', exitCode: 1);
......
......@@ -5,8 +5,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/utils.dart';
......@@ -160,7 +158,7 @@ class Tracing {
/// Download the startup trace information from the given observatory client and
/// store it to build/start_up_info.json.
Future<Null> downloadStartupTrace(VMService observatory) async {
String traceInfoFilePath = path.join(getBuildDirectory(), 'start_up_info.json');
String traceInfoFilePath = fs.path.join(getBuildDirectory(), 'start_up_info.json');
File traceInfoFile = fs.file(traceInfoFilePath);
// Delete old startup data, if any.
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/net.dart';
......@@ -35,11 +33,11 @@ class UpdatePackagesCommand extends FlutterCommand {
Future<Null> _downloadCoverageData() async {
Status status = logger.startProgress("Downloading lcov data for package:flutter...", expectSlowOperation: true);
final List<int> data = await fetchUrl(Uri.parse('https://storage.googleapis.com/flutter_infra/flutter/coverage/lcov.info'));
final String coverageDir = path.join(Cache.flutterRoot, 'packages/flutter/coverage');
fs.file(path.join(coverageDir, 'lcov.base.info'))
final String coverageDir = fs.path.join(Cache.flutterRoot, 'packages/flutter/coverage');
fs.file(fs.path.join(coverageDir, 'lcov.base.info'))
..createSync(recursive: true)
..writeAsBytesSync(data, flush: true);
fs.file(path.join(coverageDir, 'lcov.info'))
fs.file(fs.path.join(coverageDir, 'lcov.info'))
..createSync(recursive: true)
..writeAsBytesSync(data, flush: true);
status.stop();
......
......@@ -4,9 +4,8 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/os.dart';
import '../base/process.dart';
import '../cache.dart';
......@@ -60,7 +59,7 @@ class UpgradeCommand extends FlutterCommand {
printStatus('Upgrading engine...');
code = await runCommandAndStreamOutput(
<String>[
path.join(Cache.flutterRoot, 'bin', 'flutter'), '--no-color', 'precache'
fs.path.join(Cache.flutterRoot, 'bin', 'flutter'), '--no-color', 'precache'
],
workingDirectory: Cache.flutterRoot,
allowReentrantFlutter: true
......
......@@ -21,7 +21,6 @@ import 'package:linter/src/rules.dart' as linter; // ignore: implementation_impo
import 'package:cli_util/cli_util.dart' as cli_util;
import 'package:package_config/packages.dart' show Packages;
import 'package:package_config/src/packages_impl.dart' show MapPackages; // ignore: implementation_imports
import 'package:path/path.dart' as path;
import 'package:plugin/manager.dart';
import 'package:plugin/plugin.dart';
......@@ -47,7 +46,7 @@ class AnalysisDriver {
DriverOptions options;
String get sdkDir {
return options.dartSdkPath ?? path.absolute(cli_util.getSdkDir().path);
return options.dartSdkPath ?? fs.path.absolute(cli_util.getSdkDir().path);
}
List<AnalysisErrorDescription> analyze(Iterable<File> files) {
......@@ -74,7 +73,7 @@ class AnalysisDriver {
List<Source> sources = <Source>[];
ChangeSet changeSet = new ChangeSet();
for (File file in files) {
JavaFile sourceFile = new JavaFile(path.normalize(file.absolute.path));
JavaFile sourceFile = new JavaFile(fs.path.normalize(file.absolute.path));
Source source = new FileBasedSource(sourceFile, sourceFile.toURI());
Uri uri = context.sourceFactory.restoreUri(source);
if (uri != null) {
......
......@@ -4,8 +4,7 @@
import 'dart:convert';
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/process.dart';
import '../toolchain.dart';
......@@ -37,7 +36,7 @@ class DartDependencySetBuilder {
if (!line.startsWith('package:')) {
// We convert the uris so that they are relative to the project
// root.
line = path.relative(line, from: projectRootPath);
line = fs.path.relative(line, from: projectRootPath);
}
minimalDependencies.add(line);
}
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'package:package_config/packages_file.dart' as packages_file;
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
......@@ -46,7 +45,7 @@ class PackageMap {
List<String> pathSegments = packageUri.pathSegments.toList();
String packageName = pathSegments.removeAt(0);
Uri packageBase = map[packageName];
String packageRelativePath = path.joinAll(pathSegments);
String packageRelativePath = fs.path.joinAll(pathSegments);
return packageBase.resolve(packageRelativePath).path;
}
......@@ -54,7 +53,7 @@ class PackageMap {
if (fs.isFileSync(packagesPath))
return null;
String message = '$packagesPath does not exist.';
String pubspecPath = path.absolute(path.dirname(packagesPath), 'pubspec.yaml');
String pubspecPath = fs.path.absolute(fs.path.dirname(packagesPath), 'pubspec.yaml');
if (fs.isFileSync(pubspecPath))
message += '\nDid you run "flutter packages get" in this directory?';
else
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
......@@ -36,8 +34,8 @@ Future<Null> pubGet({
if (directory == null)
directory = fs.currentDirectory.path;
File pubSpecYaml = fs.file(path.join(directory, 'pubspec.yaml'));
File dotPackages = fs.file(path.join(directory, '.packages'));
File pubSpecYaml = fs.file(fs.path.join(directory, 'pubspec.yaml'));
File dotPackages = fs.file(fs.path.join(directory, '.packages'));
if (!pubSpecYaml.existsSync()) {
if (!skipIfAbsent)
......@@ -47,7 +45,7 @@ Future<Null> pubGet({
if (!checkLastModified || _shouldRunPubGet(pubSpecYaml: pubSpecYaml, dotPackages: dotPackages)) {
String command = upgrade ? 'upgrade' : 'get';
Status status = logger.startProgress("Running 'flutter packages $command' in ${path.basename(directory)}...",
Status status = logger.startProgress("Running 'flutter packages $command' in ${fs.path.basename(directory)}...",
expectSlowOperation: true);
int code = await runCommandAndStreamOutput(
<String>[sdkBinaryName('pub'), '--verbosity=warning', command, '--no-packages-dir', '--no-precompile'],
......
......@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/platform.dart';
import '../cache.dart';
/// Locate the Dart SDK.
String get dartSdkPath {
return path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
return fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
}
/// Return the platform specific name for the given Dart SDK binary. So, `pub`
/// ==> `pub.bat`. The default SDK location can be overridden with a specified
/// [sdkLocation].
String sdkBinaryName(String name, { String sdkLocation }) {
return path.absolute(path.join(sdkLocation ?? dartSdkPath, 'bin', platform.isWindows ? '$name.bat' : name));
return fs.path.absolute(fs.path.join(sdkLocation ?? dartSdkPath, 'bin', platform.isWindows ? '$name.bat' : name));
}
......@@ -9,8 +9,6 @@ import 'dart/dependencies.dart';
import 'dart/package_map.dart';
import 'asset.dart';
import 'package:path/path.dart' as pathos;
class DependencyChecker {
final DartDependencySetBuilder builder;
final Set<String> _dependencies = new Set<String>();
......@@ -38,7 +36,7 @@ class DependencyChecker {
if (path.startsWith('package:')) {
path = packageMap.pathForPackage(Uri.parse(path));
} else {
path = pathos.join(builder.projectRootPath, path);
path = fs.path.join(builder.projectRootPath, path);
}
_dependencies.add(path);
}
......
......@@ -5,8 +5,6 @@
import 'dart:async';
import 'dart:convert' show BASE64, UTF8;
import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
......@@ -298,7 +296,7 @@ class DevFS {
_httpWriter = new _DevFSHttpWriter(fsName, serviceProtocol),
fsName = fsName {
_packagesFilePath =
packagesFilePath ?? path.join(rootDirectory.path, kPackagesFileName);
packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
}
DevFS.operations(this._operations,
......@@ -308,7 +306,7 @@ class DevFS {
})
: _httpWriter = null {
_packagesFilePath =
packagesFilePath ?? path.join(rootDirectory.path, kPackagesFileName);
packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
}
final DevFSOperations _operations;
......@@ -365,7 +363,7 @@ class DevFS {
// Handle deletions.
printTrace('Scanning for deleted files');
String assetBuildDirPrefix = getAssetBuildDirectory() + path.separator;
String assetBuildDirPrefix = getAssetBuildDirectory() + fs.path.separator;
final List<String> toRemove = new List<String>();
_entries.forEach((String devicePath, DevFSContent content) {
if (!content._exists) {
......@@ -446,7 +444,7 @@ class DevFS {
void _scanBundleEntry(String archivePath, DevFSContent content, bool bundleDirty) {
// We write the assets into the AssetBundle working dir so that they
// are in the same location in DevFS and the iOS simulator.
final String devicePath = path.join(getAssetBuildDirectory(), archivePath);
final String devicePath = fs.path.join(getAssetBuildDirectory(), archivePath);
_entries[devicePath] = content;
content._exists = true;
......@@ -472,7 +470,7 @@ class DevFS {
Set<String> fileFilter}) async {
String prefix = directoryName;
if (prefix == null) {
prefix = path.relative(directory.path, from: rootDirectory.path);
prefix = fs.path.relative(directory.path, from: rootDirectory.path);
if (prefix == '.')
prefix = '';
}
......@@ -494,20 +492,20 @@ class DevFS {
continue;
}
assert((file is Link) || (file is File));
if (ignoreDotFiles && path.basename(file.path).startsWith('.')) {
if (ignoreDotFiles && fs.path.basename(file.path).startsWith('.')) {
// Skip dot files.
continue;
}
final String relativePath =
path.relative(file.path, from: directory.path);
final String devicePath = path.join(prefix, relativePath);
fs.path.relative(file.path, from: directory.path);
final String devicePath = fs.path.join(prefix, relativePath);
bool filtered = false;
if ((fileFilter != null) &&
!fileFilter.contains(devicePath)) {
if (packagesDirectoryName != null) {
// Double check the filter for packages/packagename/
final String packagesDevicePath =
path.join(packagesDirectoryName, relativePath);
fs.path.join(packagesDirectoryName, relativePath);
if (!fileFilter.contains(packagesDevicePath)) {
// File was not in the filter set.
filtered = true;
......@@ -544,13 +542,13 @@ class DevFS {
// This project's own package.
final bool isProjectPackage = uri.toString() == 'lib/';
final String directoryName =
isProjectPackage ? 'lib' : path.join('packages', packageName);
isProjectPackage ? 'lib' : fs.path.join('packages', packageName);
// If this is the project's package, we need to pass both
// package:<package_name> and lib/ as paths to be checked against
// the filter because we must support both package: imports and relative
// path imports within the project's own code.
final String packagesDirectoryName =
isProjectPackage ? path.join('packages', packageName) : null;
isProjectPackage ? fs.path.join('packages', packageName) : null;
Directory directory = fs.directory(uri);
bool packageExists =
await _scanDirectory(directory,
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert' show UTF8;
import 'package:archive/archive.dart';
import 'package:path/path.dart' as path;
import 'android/android_workflow.dart';
import 'base/common.dart';
......@@ -300,8 +299,8 @@ abstract class IntelliJValidator extends DoctorValidator {
String _readPackageVersion(String packageName) {
String jarPath = packageName.endsWith('.jar')
? path.join(pluginsPath, packageName)
: path.join(pluginsPath, packageName, 'lib', '$packageName.jar');
? fs.path.join(pluginsPath, packageName)
: fs.path.join(pluginsPath, packageName, 'lib', '$packageName.jar');
// TODO(danrubel) look for a better way to extract a single 2K file from the zip
// rather than reading the entire file into memory.
try {
......@@ -318,7 +317,7 @@ abstract class IntelliJValidator extends DoctorValidator {
}
bool hasPackage(String packageName) {
String packagePath = path.join(pluginsPath, packageName);
String packagePath = fs.path.join(pluginsPath, packageName);
if (packageName.endsWith('.jar'))
return fs.isFileSync(packagePath);
return fs.isDirectorySync(packagePath);
......@@ -356,18 +355,18 @@ class IntelliJValidatorOnLinuxAndWindows extends IntelliJValidator {
for (FileSystemEntity dir in fs.directory(homeDirPath).listSync()) {
if (dir is Directory) {
String name = path.basename(dir.path);
String name = fs.path.basename(dir.path);
IntelliJValidator._idToTitle.forEach((String id, String title) {
if (name.startsWith('.$id')) {
String version = name.substring(id.length + 1);
String installPath;
try {
installPath = fs.file(path.join(dir.path, 'system', '.home')).readAsStringSync();
installPath = fs.file(fs.path.join(dir.path, 'system', '.home')).readAsStringSync();
} catch (e) {
// ignored
}
if (installPath != null && fs.isDirectorySync(installPath)) {
String pluginsPath = path.join(dir.path, 'config', 'plugins');
String pluginsPath = fs.path.join(dir.path, 'config', 'plugins');
addValidator(title, version, installPath, pluginsPath);
}
}
......@@ -392,10 +391,10 @@ class IntelliJValidatorOnMac extends IntelliJValidator {
static Iterable<DoctorValidator> get installed {
List<DoctorValidator> validators = <DoctorValidator>[];
List<String> installPaths = <String>['/Applications', path.join(homeDirPath, 'Applications')];
List<String> installPaths = <String>['/Applications', fs.path.join(homeDirPath, 'Applications')];
void checkForIntelliJ(Directory dir) {
String name = path.basename(dir.path);
String name = fs.path.basename(dir.path);
_dirNameToId.forEach((String dirName, String id) {
if (name == dirName) {
String title = IntelliJValidator._idToTitle[id];
......@@ -437,7 +436,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator {
if (_version == null) {
String plist;
try {
plist = fs.file(path.join(installPath, 'Contents', 'Info.plist')).readAsStringSync();
plist = fs.file(fs.path.join(installPath, 'Contents', 'Info.plist')).readAsStringSync();
int index = plist.indexOf('CFBundleShortVersionString');
if (index > 0) {
int start = plist.indexOf('<string>', index);
......@@ -462,7 +461,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator {
List<String> split = version.split('.');
String major = split[0];
String minor = split[1];
return path.join(homeDirPath, 'Library', 'Application Support', '$id$major.$minor');
return fs.path.join(homeDirPath, 'Library', 'Application Support', '$id$major.$minor');
}
}
......
......@@ -4,8 +4,6 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import 'asset.dart';
import 'base/common.dart';
import 'base/file_system.dart';
......@@ -20,9 +18,9 @@ import 'zip.dart';
const String defaultMainPath = 'lib/main.dart';
const String defaultAssetBasePath = '.';
const String defaultManifestPath = 'pubspec.yaml';
String get defaultFlxOutputPath => path.join(getBuildDirectory(), 'app.flx');
String get defaultSnapshotPath => path.join(getBuildDirectory(), 'snapshot_blob.bin');
String get defaultDepfilePath => path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
String get defaultFlxOutputPath => fs.path.join(getBuildDirectory(), 'app.flx');
String get defaultSnapshotPath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin');
String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
const String defaultPrivateKeyPath = 'privatekey.der';
const String _kSnapshotKey = 'snapshot_blob.bin';
......@@ -89,7 +87,7 @@ Future<Null> build({
snapshotPath ??= defaultSnapshotPath;
depfilePath ??= defaultDepfilePath;
workingDirPath ??= getAssetBuildDirectory();
packagesPath ??= path.absolute(PackageMap.globalPackagesPath);
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
File snapshotFile;
if (!precompiledSnapshot) {
......@@ -135,7 +133,7 @@ Future<Null> assemble({
}) async {
outputPath ??= defaultFlxOutputPath;
workingDirPath ??= getAssetBuildDirectory();
packagesPath ??= path.absolute(PackageMap.globalPackagesPath);
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
printTrace('Building $outputPath');
// Build the asset bundle.
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert' show JSON;
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import '../application_package.dart';
import '../base/context.dart';
......@@ -133,11 +132,11 @@ Future<XcodeBuildResult> buildXcodeProject({
List<FileSystemEntity> contents = fs.directory(app.appDirectory).listSync();
for (FileSystemEntity entity in contents) {
if (path.extension(entity.path) == '.xcworkspace') {
if (fs.path.extension(entity.path) == '.xcworkspace') {
commands.addAll(<String>[
'-workspace', path.basename(entity.path),
'-scheme', path.basenameWithoutExtension(entity.path),
"BUILD_DIR=${path.absolute(getIosBuildDirectory())}",
'-workspace', fs.path.basename(entity.path),
'-scheme', fs.path.basenameWithoutExtension(entity.path),
"BUILD_DIR=${fs.path.absolute(getIosBuildDirectory())}",
]);
break;
}
......@@ -191,7 +190,7 @@ Future<XcodeBuildResult> buildXcodeProject({
Match match = regexp.firstMatch(result.stdout);
String outputDir;
if (match != null)
outputDir = path.join(app.appDirectory, match.group(1));
outputDir = fs.path.join(app.appDirectory, match.group(1));
return new XcodeBuildResult(success:true, output: outputDir);
}
}
......@@ -320,17 +319,17 @@ Future<Null> _addServicesToBundle(Directory bundle) async {
printTrace("Found ${services.length} service definition(s).");
// Step 2: Copy framework dylibs to the correct spot for xcodebuild to pick up.
Directory frameworksDirectory = fs.directory(path.join(bundle.path, "Frameworks"));
Directory frameworksDirectory = fs.directory(fs.path.join(bundle.path, "Frameworks"));
await _copyServiceFrameworks(services, frameworksDirectory);
// Step 3: Copy the service definitions manifest at the correct spot for
// xcodebuild to pick up.
File manifestFile = fs.file(path.join(bundle.path, "ServiceDefinitions.json"));
File manifestFile = fs.file(fs.path.join(bundle.path, "ServiceDefinitions.json"));
_copyServiceDefinitionsManifest(services, manifestFile);
}
Future<Null> _copyServiceFrameworks(List<Map<String, String>> services, Directory frameworksDirectory) async {
printTrace("Copying service frameworks to '${path.absolute(frameworksDirectory.path)}'.");
printTrace("Copying service frameworks to '${fs.path.absolute(frameworksDirectory.path)}'.");
frameworksDirectory.createSync(recursive: true);
for (Map<String, String> service in services) {
String dylibPath = await getServiceFromUrl(service['ios-framework'], service['root'], service['name']);
......@@ -351,7 +350,7 @@ void _copyServiceDefinitionsManifest(List<Map<String, String>> services, File ma
'name': service['name'],
// Since we have already moved it to the Frameworks directory. Strip away
// the directory and basenames.
'framework': path.basenameWithoutExtension(service['ios-framework'])
'framework': fs.path.basenameWithoutExtension(service['ios-framework'])
}).toList();
Map<String, dynamic> json = <String, dynamic>{ 'services' : jsonServices };
manifest.writeAsStringSync(JSON.encode(json), mode: FileMode.WRITE, flush: true);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/process.dart';
......@@ -20,7 +18,7 @@ String getValueFromFile(String plistFilePath, String key) {
if (!fs.isFileSync(plistFilePath))
return null;
String normalizedPlistPath = path.withoutExtension(path.absolute(plistFilePath));
String normalizedPlistPath = fs.path.withoutExtension(fs.path.absolute(plistFilePath));
try {
String value = runCheckedSync(<String>[
......
......@@ -6,8 +6,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
import 'package:path/path.dart' as path;
import '../application_package.dart';
import '../base/common.dart';
import '../base/context.dart';
......@@ -319,17 +317,17 @@ class IOSSimulator extends Device {
Map<ApplicationPackage, _IOSSimulatorLogReader> _logReaders;
_IOSSimulatorDevicePortForwarder _portForwarder;
String get xcrunPath => path.join('/usr', 'bin', 'xcrun');
String get xcrunPath => fs.path.join('/usr', 'bin', 'xcrun');
String _getSimulatorPath() {
return path.join(homeDirPath, 'Library', 'Developer', 'CoreSimulator', 'Devices', id);
return fs.path.join(homeDirPath, 'Library', 'Developer', 'CoreSimulator', 'Devices', id);
}
String _getSimulatorAppHomeDirectory(ApplicationPackage app) {
String simulatorPath = _getSimulatorPath();
if (simulatorPath == null)
return null;
return path.join(simulatorPath, 'data');
return fs.path.join(simulatorPath, 'data');
}
@override
......@@ -438,9 +436,9 @@ class IOSSimulator extends Device {
if (!prebuiltApplication) {
args.addAll(<String>[
'--flx=${path.absolute(path.join(getBuildDirectory(), 'app.flx'))}',
'--dart-main=${path.absolute(mainPath)}',
'--packages=${path.absolute('.packages')}',
'--flx=${fs.path.absolute(fs.path.join(getBuildDirectory(), 'app.flx'))}',
'--dart-main=${fs.path.absolute(mainPath)}',
'--packages=${fs.path.absolute('.packages')}',
]);
}
......@@ -520,7 +518,7 @@ class IOSSimulator extends Device {
throwToolExit('Could not find the built application bundle at ${bundle.path}.');
// Step 3: Install the updated bundle to the simulator.
SimControl.instance.install(id, path.absolute(bundle.path));
SimControl.instance.install(id, fs.path.absolute(bundle.path));
}
Future<Null> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app) =>
......@@ -536,14 +534,14 @@ class IOSSimulator extends Device {
ApplicationPackage app, String localFile, String targetFile) async {
if (p.platform.isMacOS) {
String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
runCheckedSync(<String>['cp', localFile, path.join(simulatorHomeDirectory, targetFile)]);
runCheckedSync(<String>['cp', localFile, fs.path.join(simulatorHomeDirectory, targetFile)]);
return true;
}
return false;
}
String get logFilePath {
return path.join(homeDirPath, 'Library', 'Logs', 'CoreSimulator', id, 'system.log');
return fs.path.join(homeDirPath, 'Library', 'Logs', 'CoreSimulator', id, 'system.log');
}
@override
......@@ -587,13 +585,13 @@ class IOSSimulator extends Device {
@override
Future<Null> takeScreenshot(File outputFile) async {
Directory desktopDir = fs.directory(path.join(homeDirPath, 'Desktop'));
Directory desktopDir = fs.directory(fs.path.join(homeDirPath, 'Desktop'));
// 'Simulator Screen Shot Mar 25, 2016, 2.59.43 PM.png'
Set<File> getScreenshots() {
return new Set<File>.from(desktopDir.listSync().where((FileSystemEntity entity) {
String name = path.basename(entity.path);
String name = fs.path.basename(entity.path);
return entity is File && name.startsWith('Simulator') && name.endsWith('.png');
}));
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/process.dart';
import '../build_info.dart';
......@@ -18,11 +16,11 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t
localsBuffer.writeln('// This is a generated file; do not edit or check into version control.');
String flutterRoot = path.normalize(Cache.flutterRoot);
String flutterRoot = fs.path.normalize(Cache.flutterRoot);
localsBuffer.writeln('FLUTTER_ROOT=$flutterRoot');
// This holds because requiresProjectRoot is true for this command
String applicationRoot = path.normalize(fs.currentDirectory.path);
String applicationRoot = fs.path.normalize(fs.currentDirectory.path);
localsBuffer.writeln('FLUTTER_APPLICATION_PATH=$applicationRoot');
// Relative to FLUTTER_APPLICATION_PATH, which is [Directory.current].
......@@ -36,19 +34,19 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t
localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
String flutterFrameworkDir = path.normalize(tools.getEngineArtifactsDirectory(TargetPlatform.ios, mode).path);
String flutterFrameworkDir = fs.path.normalize(tools.getEngineArtifactsDirectory(TargetPlatform.ios, mode).path);
localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=$flutterFrameworkDir');
if (tools.isLocalEngine)
localsBuffer.writeln('LOCAL_ENGINE=${tools.engineBuildPath}');
File localsFile = fs.file(path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
File localsFile = fs.file(fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
localsFile.createSync(recursive: true);
localsFile.writeAsStringSync(localsBuffer.toString());
}
Map<String, String> getXcodeBuildSettings(String xcodeProjPath, String target) {
String absProjPath = path.absolute(xcodeProjPath);
String absProjPath = fs.path.absolute(xcodeProjPath);
String out = runCheckedSync(<String>[
'/usr/bin/xcodebuild', '-project', absProjPath, '-target', target, '-showBuildSettings'
]);
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'application_package.dart';
import 'asset.dart';
......@@ -37,7 +36,7 @@ abstract class ResidentRunner {
_mainPath = findMainDartFile(target);
_projectRootPath = projectRootPath ?? fs.currentDirectory.path;
_packagesFilePath =
packagesFilePath ?? path.absolute(PackageMap.globalPackagesPath);
packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath);
if (projectAssets != null)
_assetBundle = new AssetBundle.fixed(_projectRootPath, projectAssets);
else
......@@ -133,7 +132,7 @@ abstract class ResidentRunner {
}
int sizeKB = (await outputFile.length()) ~/ 1024;
status.stop();
printStatus('Screenshot written to ${path.relative(outputFile.path)} (${sizeKB}kB).');
printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).');
} catch (error) {
status.stop();
printError('Error taking screenshot: $error');
......@@ -377,9 +376,9 @@ class OperationResult {
String findMainDartFile([String target]) {
if (target == null)
target = '';
String targetPath = path.absolute(target);
String targetPath = fs.path.absolute(target);
if (fs.isDirectorySync(targetPath))
return path.join(targetPath, 'lib', 'main.dart');
return fs.path.join(targetPath, 'lib', 'main.dart');
else
return targetPath;
}
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:stack_trace/stack_trace.dart';
import 'application_package.dart';
......@@ -257,7 +256,7 @@ class HotRunner extends ResidentRunner {
DevFS _devFS;
Future<Uri> _initDevFS() {
String fsName = path.basename(projectRootPath);
String fsName = fs.path.basename(projectRootPath);
_devFS = new DevFS(vmService,
fsName,
fs.directory(projectRootPath),
......@@ -324,7 +323,7 @@ class HotRunner extends ResidentRunner {
Future<Null> _launchFromDevFS(ApplicationPackage package,
String mainScript) async {
String entryPath = path.relative(mainScript, from: projectRootPath);
String entryPath = fs.path.relative(mainScript, from: projectRootPath);
String deviceEntryPath =
_devFS.baseUri.resolve(entryPath).toFilePath();
String devicePackagesPath =
......@@ -435,7 +434,7 @@ class HotRunner extends ResidentRunner {
return new OperationResult(1, 'Dart Source Error');
String reloadMessage;
try {
String entryPath = path.relative(mainPath, from: projectRootPath);
String entryPath = fs.path.relative(mainPath, from: projectRootPath);
String deviceEntryPath =
_devFS.baseUri.resolve(entryPath).toFilePath();
String devicePackagesPath =
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path;
import '../android/android_sdk.dart';
import '../base/common.dart';
......@@ -124,10 +123,10 @@ class FlutterCommandRunner extends CommandRunner<Null> {
if (platform.script.scheme == 'data')
return '../..'; // we're running as a test
String script = platform.script.toFilePath();
if (path.basename(script) == kSnapshotFileName)
return path.dirname(path.dirname(path.dirname(script)));
if (path.basename(script) == kFlutterToolsScriptFileName)
return path.dirname(path.dirname(path.dirname(path.dirname(script))));
if (fs.path.basename(script) == kSnapshotFileName)
return fs.path.dirname(fs.path.dirname(fs.path.dirname(script)));
if (fs.path.basename(script) == kFlutterToolsScriptFileName)
return fs.path.dirname(fs.path.dirname(fs.path.dirname(fs.path.dirname(script))));
// If run from a bare script within the repo.
if (script.contains('flutter/packages/'))
......@@ -188,7 +187,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// We must set Cache.flutterRoot early because other features use it (e.g.
// enginePath's initialiser uses it).
Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
Cache.flutterRoot = fs.path.normalize(fs.path.absolute(globalResults['flutter-root']));
if (platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true')
await Cache.lock();
......@@ -199,7 +198,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
_checkFlutterCopy();
if (globalResults.wasParsed('packages'))
PackageMap.globalPackagesPath = path.normalize(path.absolute(globalResults['packages']));
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(globalResults['packages']));
// See if the user specified a specific device.
deviceManager.specifiedDeviceId = globalResults['device-id'];
......@@ -224,7 +223,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
}
String _tryEnginePath(String enginePath) {
if (fs.isDirectorySync(path.join(enginePath, 'out')))
if (fs.isDirectorySync(fs.path.join(enginePath, 'out')))
return enginePath;
return null;
}
......@@ -236,15 +235,15 @@ class FlutterCommandRunner extends CommandRunner<Null> {
try {
Uri engineUri = new PackageMap(PackageMap.globalPackagesPath).map[kFlutterEnginePackageName];
if (engineUri != null) {
engineSourcePath = path.dirname(path.dirname(path.dirname(path.dirname(engineUri.path))));
bool dirExists = fs.isDirectorySync(path.join(engineSourcePath, 'out'));
engineSourcePath = fs.path.dirname(fs.path.dirname(fs.path.dirname(fs.path.dirname(engineUri.path))));
bool dirExists = fs.isDirectorySync(fs.path.join(engineSourcePath, 'out'));
if (engineSourcePath == '/' || engineSourcePath.isEmpty || !dirExists)
engineSourcePath = null;
}
} on FileSystemException { } on FormatException { }
if (engineSourcePath == null)
engineSourcePath = _tryEnginePath(path.join(Cache.flutterRoot, '../engine/src'));
engineSourcePath = _tryEnginePath(fs.path.join(Cache.flutterRoot, '../engine/src'));
if (engineSourcePath == null) {
printError('Unable to detect local Flutter engine build directory.\n'
......@@ -274,7 +273,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
throw new ProcessExit(2);
}
String engineBuildPath = path.normalize(path.join(enginePath, 'out', localEngine));
String engineBuildPath = fs.path.normalize(fs.path.join(enginePath, 'out', localEngine));
if (!fs.isDirectorySync(engineBuildPath)) {
printError('No Flutter engine build found at $engineBuildPath.');
throw new ProcessExit(2);
......@@ -290,16 +289,16 @@ class FlutterCommandRunner extends CommandRunner<Null> {
/// Get all pub packages in the Flutter repo.
List<Directory> getRepoPackages() {
return _gatherProjectPaths(path.absolute(Cache.flutterRoot))
return _gatherProjectPaths(fs.path.absolute(Cache.flutterRoot))
.map((String dir) => fs.directory(dir))
.toList();
}
static List<String> _gatherProjectPaths(String rootPath) {
if (fs.isFileSync(path.join(rootPath, '.dartignore')))
if (fs.isFileSync(fs.path.join(rootPath, '.dartignore')))
return <String>[];
if (fs.isFileSync(path.join(rootPath, 'pubspec.yaml')))
if (fs.isFileSync(fs.path.join(rootPath, 'pubspec.yaml')))
return <String>[rootPath];
return fs.directory(rootPath)
......@@ -312,15 +311,15 @@ class FlutterCommandRunner extends CommandRunner<Null> {
/// Get the entry-points we want to analyze in the Flutter repo.
List<Directory> getRepoAnalysisEntryPoints() {
final String rootPath = path.absolute(Cache.flutterRoot);
final String rootPath = fs.path.absolute(Cache.flutterRoot);
final List<Directory> result = <Directory>[
// not bin, and not the root
fs.directory(path.join(rootPath, 'dev')),
fs.directory(path.join(rootPath, 'examples')),
fs.directory(fs.path.join(rootPath, 'dev')),
fs.directory(fs.path.join(rootPath, 'examples')),
];
// And since analyzer refuses to look at paths that end in "packages/":
result.addAll(
_gatherProjectPaths(path.join(rootPath, 'packages'))
_gatherProjectPaths(fs.path.join(rootPath, 'packages'))
.map<Directory>((String path) => fs.directory(path))
);
return result;
......@@ -329,7 +328,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
void _checkFlutterCopy() {
// If the current directory is contained by a flutter repo, check that it's
// the same flutter that is currently running.
String directory = path.normalize(path.absolute(fs.currentDirectory.path));
String directory = fs.path.normalize(fs.path.absolute(fs.currentDirectory.path));
// Check if the cwd is a flutter dir.
while (directory.isNotEmpty) {
......@@ -347,7 +346,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
break;
}
String parent = path.dirname(directory);
String parent = fs.path.dirname(directory);
if (parent == directory)
break;
directory = parent;
......@@ -361,7 +360,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
if (flutterUri != null && (flutterUri.scheme == 'file' || flutterUri.scheme == '')) {
// .../flutter/packages/flutter/lib
Uri rootUri = flutterUri.resolve('../../..');
String flutterPath = path.normalize(fs.file(rootUri).absolute.path);
String flutterPath = fs.path.normalize(fs.file(rootUri).absolute.path);
if (!fs.isDirectorySync(flutterPath)) {
printError(
......@@ -394,14 +393,14 @@ class FlutterCommandRunner extends CommandRunner<Null> {
// Check if `bin/flutter` and `bin/cache/engine.stamp` exist.
bool _isDirectoryFlutterRepo(String directory) {
return
fs.isFileSync(path.join(directory, 'bin/flutter')) &&
fs.isFileSync(path.join(directory, 'bin/cache/engine.stamp'));
fs.isFileSync(fs.path.join(directory, 'bin/flutter')) &&
fs.isFileSync(fs.path.join(directory, 'bin/cache/engine.stamp'));
}
}
bool _compareResolvedPaths(String path1, String path2) {
path1 = fs.directory(path.absolute(path1)).resolveSymbolicLinksSync();
path2 = fs.directory(path.absolute(path2)).resolveSymbolicLinksSync();
path1 = fs.directory(fs.path.absolute(path1)).resolveSymbolicLinksSync();
path2 = fs.directory(fs.path.absolute(path2)).resolveSymbolicLinksSync();
return path1 == path2;
}
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
import 'base/file_system.dart';
......@@ -86,7 +85,7 @@ Future<String> getServiceFromUrl(
return await cache.getThirdPartyFile(url, serviceName, unzip: unzip);
} else {
// Assume url is a path relative to the service's root dir.
return path.join(rootDir, url);
return fs.path.join(rootDir, url);
}
}
......@@ -107,7 +106,7 @@ File generateServiceDefinitions(
}).toList();
Map<String, dynamic> json = <String, dynamic>{ 'services': services };
File servicesFile = fs.file(path.join(dir, 'services.json'));
File servicesFile = fs.file(fs.path.join(dir, 'services.json'));
servicesFile.writeAsStringSync(JSON.encode(json), mode: FileMode.WRITE, flush: true);
return servicesFile;
}
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'package:mustache/mustache.dart' as mustache;
import 'package:path/path.dart' as path;
import 'base/file_system.dart';
import 'cache.dart';
......@@ -39,14 +38,14 @@ class Template {
continue;
}
String relativePath = path.relative(entity.path,
String relativePath = fs.path.relative(entity.path,
from: baseDir.absolute.path);
if (relativePath.contains(_kTemplateExtension)) {
// If '.tmpl' appears anywhere within the path of this entity, it is
// is a candidate for rendering. This catches cases where the folder
// itself is a template.
_templateFilePaths[relativePath] = path.absolute(entity.path);
_templateFilePaths[relativePath] = fs.path.absolute(entity.path);
}
}
}
......@@ -71,14 +70,14 @@ class Template {
String destinationDirPath = destination.absolute.path;
_templateFilePaths.forEach((String relativeDestPath, String absoluteSrcPath) {
String finalDestinationPath = path
String finalDestinationPath = fs.path
.join(destinationDirPath, relativeDestPath)
.replaceAll(_kCopyTemplateExtension, '')
.replaceAll(_kTemplateExtension, '');
if (projectName != null)
finalDestinationPath = finalDestinationPath.replaceAll('projectName', projectName);
File finalDestinationFile = fs.file(finalDestinationPath);
String relativePathForLogging = path.relative(finalDestinationFile.path);
String relativePathForLogging = fs.path.relative(finalDestinationFile.path);
// Step 1: Check if the file needs to be overwritten.
......@@ -132,7 +131,7 @@ class Template {
}
Directory _templateDirectoryInPackage(String name) {
String templatesDir = path.join(Cache.flutterRoot,
String templatesDir = fs.path.join(Cache.flutterRoot,
'packages', 'flutter_tools', 'templates');
return fs.directory(path.join(templatesDir, name));
return fs.directory(fs.path.join(templatesDir, name));
}
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:coverage/coverage.dart';
import 'package:path/path.dart' as path;
import '../base/file_system.dart';
import '../base/io.dart';
......@@ -66,7 +65,7 @@ class CoverageCollector {
if (formatter == null) {
Resolver resolver = new Resolver(packagesPath: PackageMap.globalPackagesPath);
String packagePath = fs.currentDirectory.path;
List<String> reportOn = <String>[path.join(packagePath, 'lib')];
List<String> reportOn = <String>[fs.path.join(packagePath, 'lib')];
formatter = new LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath);
}
String result = await formatter.format(_globalHitmap);
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:stream_channel/stream_channel.dart';
import 'package:test/src/backend/test_platform.dart'; // ignore: implementation_imports
......@@ -164,7 +163,7 @@ class _FlutterPlatform extends PlatformPlugin {
File listenerFile = fs.file('${temporaryDirectory.path}/listener.dart');
listenerFile.createSync();
listenerFile.writeAsStringSync(_generateTestMain(
testUrl: path.toUri(path.absolute(testPath)).toString(),
testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(),
encodedWebsocketUrl: Uri.encodeComponent("ws://${_kHost.address}:${server.port}"),
));
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'base/context.dart';
import 'base/file_system.dart';
import 'build_info.dart';
......@@ -56,27 +54,27 @@ class ToolConfiguration {
// Create something like `android-arm` or `android-arm-release`.
String dirName = getNameForTargetPlatform(platform) + suffix;
Directory engineDir = cache.getArtifactDirectory('engine');
return fs.directory(path.join(engineDir.path, dirName));
return fs.directory(fs.path.join(engineDir.path, dirName));
}
}
String getHostToolPath(HostTool tool) {
if (engineBuildPath == null) {
return path.join(cache.getArtifactDirectory('engine').path,
return fs.path.join(cache.getArtifactDirectory('engine').path,
getNameForHostPlatform(getCurrentHostPlatform()),
_kHostToolFileName[tool]);
}
if (tool == HostTool.SkySnapshot) {
String clangPath = path.join(engineBuildPath, 'clang_x64', 'sky_snapshot');
String clangPath = fs.path.join(engineBuildPath, 'clang_x64', 'sky_snapshot');
if (fs.isFileSync(clangPath))
return clangPath;
return path.join(engineBuildPath, 'sky_snapshot');
return fs.path.join(engineBuildPath, 'sky_snapshot');
} else if (tool == HostTool.SkyShell) {
if (getCurrentHostPlatform() == HostPlatform.linux_x64) {
return path.join(engineBuildPath, 'sky_shell');
return fs.path.join(engineBuildPath, 'sky_shell');
} else if (getCurrentHostPlatform() == HostPlatform.darwin_x64) {
return path.join(engineBuildPath, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell');
return fs.path.join(engineBuildPath, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell');
}
}
......
......@@ -7,10 +7,10 @@ import 'dart:convert' show BASE64;
import 'package:json_rpc_2/error_code.dart' as rpc_error_code;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:path/path.dart' as path;
import 'package:stream_channel/stream_channel.dart';
import 'package:web_socket_channel/io.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'globals.dart';
......@@ -35,7 +35,7 @@ class VMService {
/// Requests made via the returns [VMService] time out after [requestTimeout]
/// amount of time, which is [kDefaultRequestTimeout] by default.
static Future<VMService> connect(Uri httpUri, { Duration requestTimeout: kDefaultRequestTimeout }) async {
Uri wsUri = httpUri.replace(scheme: 'ws', path: path.join(httpUri.path, 'ws'));
Uri wsUri = httpUri.replace(scheme: 'ws', path: fs.path.join(httpUri.path, 'ws'));
WebSocket ws;
try {
ws = await WebSocket.connect(wsUri.toString());
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'package:archive/archive.dart';
import 'package:path/path.dart' as path;
import 'devfs.dart';
import 'base/file_system.dart';
......@@ -74,7 +73,7 @@ class _ZipToolBuilder extends ZipBuilder {
int count = entries.length;
entries.forEach((String archivePath, DevFSContent content) {
content.contentsAsBytes().then<Null>((List<int> data) {
File file = fs.file(path.join(zipBuildDir.path, archivePath));
File file = fs.file(fs.path.join(zipBuildDir.path, archivePath));
file.parent.createSync(recursive: true);
file.writeAsBytes(data).then<Null>((File value) {
count -= 1;
......
......@@ -21,7 +21,6 @@ dependencies:
meta: ^1.0.4
mustache: ^0.2.5
package_config: '>=0.1.5 <2.0.0'
path: ^1.4.0
platform: 1.0.1
process: 2.0.1
pub_semver: ^1.0.0
......
......@@ -31,6 +31,7 @@ import 'devices_test.dart' as devices_test;
import 'doctor_test.dart' as doctor_test;
import 'drive_test.dart' as drive_test;
import 'forbid_dart_io_test.dart' as forbid_dart_io_test;
import 'forbid_package_path_test.dart' as forbid_package_path_test;
import 'format_test.dart' as format_test;
import 'hot_test.dart' as hot_test;
import 'install_test.dart' as install_test;
......@@ -70,6 +71,7 @@ void main() {
doctor_test.main();
drive_test.main();
forbid_dart_io_test.main();
forbid_package_path_test.main();
format_test.main();
hot_test.main();
install_test.main();
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/commands/analyze_continuously.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -71,12 +70,12 @@ void main() {
}
void _createSampleProject(Directory directory, { bool brokenCode: false }) {
File pubspecFile = fs.file(path.join(directory.path, 'pubspec.yaml'));
File pubspecFile = fs.file(fs.path.join(directory.path, 'pubspec.yaml'));
pubspecFile.writeAsStringSync('''
name: foo_project
''');
File dartFile = fs.file(path.join(directory.path, 'lib', 'main.dart'));
File dartFile = fs.file(fs.path.join(directory.path, 'lib', 'main.dart'));
dartFile.parent.createSync();
dartFile.writeAsStringSync('''
void main() {
......
......@@ -4,7 +4,6 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/commands/analyze.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
......@@ -24,10 +23,10 @@ void main() {
group('analyze', () {
testUsingContext('flutter analyze with two files with the same name', () async {
File dartFileA = fs.file(path.join(tempDir.path, 'a.dart'));
File dartFileA = fs.file(fs.path.join(tempDir.path, 'a.dart'));
dartFileA.parent.createSync();
dartFileA.writeAsStringSync('library test;');
File dartFileB = fs.file(path.join(tempDir.path, 'b.dart'));
File dartFileB = fs.file(fs.path.join(tempDir.path, 'b.dart'));
dartFileB.writeAsStringSync('library test;');
AnalyzeCommand command = new AnalyzeCommand();
......
......@@ -6,7 +6,6 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/analyze_base.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -28,9 +27,9 @@ void main() {
testUsingContext('inRepo', () {
// Absolute paths
expect(inRepo(<String>[tempDir.path]), isFalse);
expect(inRepo(<String>[path.join(tempDir.path, 'foo')]), isFalse);
expect(inRepo(<String>[fs.path.join(tempDir.path, 'foo')]), isFalse);
expect(inRepo(<String>[Cache.flutterRoot]), isTrue);
expect(inRepo(<String>[path.join(Cache.flutterRoot, 'foo')]), isTrue);
expect(inRepo(<String>[fs.path.join(Cache.flutterRoot, 'foo')]), isTrue);
// Relative paths
String oldWorkingDirectory = fs.currentDirectory.path;
try {
......
......@@ -4,7 +4,6 @@
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -71,6 +70,6 @@ Directory _createSdkDirectory({ bool withAndroidN: false }) {
}
void _createSdkFile(Directory dir, String filePath) {
File file = fs.file(path.join(dir.path, filePath));
File file = fs.file(fs.path.join(dir.path, filePath));
file.createSync(recursive: true);
}
......@@ -6,7 +6,6 @@ import 'dart:convert';
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
......@@ -16,7 +15,7 @@ void main() {
String projectRoot = tempDir.path;
String assetPath = 'banana.txt';
String assetContents = 'banana';
File tempFile = fs.file(path.join(projectRoot, assetPath));
File tempFile = fs.file(fs.path.join(projectRoot, assetPath));
tempFile.parent.createSync(recursive: true);
tempFile.writeAsBytesSync(UTF8.encode(assetContents));
......
......@@ -4,7 +4,6 @@
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
......@@ -12,7 +11,7 @@ void main() {
setUp(() {
Directory tempDiretory = fs.systemTempDirectory.createTempSync('flutter_test');
File file = fs.file(path.join(tempDiretory.path, '.settings'));
File file = fs.file(fs.path.join(tempDiretory.path, '.settings'));
config = new Config(file);
});
......
......@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
......@@ -123,9 +122,9 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as
args.add(dir.path);
await runner.run(args);
String mainPath = path.join(dir.path, 'lib', 'main.dart');
String mainPath = fs.path.join(dir.path, 'lib', 'main.dart');
expect(fs.file(mainPath).existsSync(), true);
String flutterToolsPath = path.absolute(path.join('bin', 'flutter_tools.dart'));
String flutterToolsPath = fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart'));
ProcessResult exec = Process.runSync(
'$dartSdkPath/bin/dart', <String>[flutterToolsPath, 'analyze'],
workingDirectory: dir.path
......
......@@ -5,19 +5,19 @@
import 'dart:io' as io;
import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
void main() {
group('DartDependencySetBuilder', () {
final String basePath = path.dirname(platform.script.path);
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
final String basePath = fs.path.dirname(platform.script.path);
final String dataPath = fs.path.join(basePath, 'data', 'dart_dependencies_test');
testUsingContext('good', () {
final String testPath = path.join(dataPath, 'good');
final String mainPath = path.join(testPath, 'main.dart');
final String packagesPath = path.join(testPath, '.packages');
final String testPath = fs.path.join(dataPath, 'good');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
DartDependencySetBuilder builder =
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
Set<String> dependencies = builder.build();
......@@ -25,9 +25,9 @@ void main() {
expect(dependencies.contains('foo.dart'), isTrue);
});
testUsingContext('syntax_error', () {
final String testPath = path.join(dataPath, 'syntax_error');
final String mainPath = path.join(testPath, 'main.dart');
final String packagesPath = path.join(testPath, '.packages');
final String testPath = fs.path.join(dataPath, 'syntax_error');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
DartDependencySetBuilder builder =
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
try {
......
......@@ -11,15 +11,14 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/devices.dart';
import 'package:flutter_tools/src/dart/dependencies.dart';
import 'package:flutter_tools/src/dependency_checker.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
import 'src/context.dart';
void main() {
group('DependencyChecker', () {
final String basePath = path.dirname(path.fromUri(platform.script));
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
final String basePath = fs.path.dirname(fs.path.fromUri(platform.script));
final String dataPath = fs.path.join(basePath, 'data', 'dart_dependencies_test');
MemoryFileSystem testFileSystem;
setUp(() {
......@@ -28,11 +27,11 @@ void main() {
});
testUsingContext('good', () {
final String testPath = path.join(dataPath, 'good');
final String mainPath = path.join(testPath, 'main.dart');
final String fooPath = path.join(testPath, 'foo.dart');
final String barPath = path.join(testPath, 'lib', 'bar.dart');
final String packagesPath = path.join(testPath, '.packages');
final String testPath = fs.path.join(dataPath, 'good');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String fooPath = fs.path.join(testPath, 'foo.dart');
final String barPath = fs.path.join(testPath, 'lib', 'bar.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
DartDependencySetBuilder builder =
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
DependencyChecker dependencyChecker =
......@@ -59,10 +58,10 @@ void main() {
expect(dependencyChecker.check(baseTime), isTrue);
});
testUsingContext('syntax error', () {
final String testPath = path.join(dataPath, 'syntax_error');
final String mainPath = path.join(testPath, 'main.dart');
final String fooPath = path.join(testPath, 'foo.dart');
final String packagesPath = path.join(testPath, '.packages');
final String testPath = fs.path.join(dataPath, 'syntax_error');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String fooPath = fs.path.join(testPath, 'foo.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
DartDependencySetBuilder builder =
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
......@@ -89,7 +88,7 @@ void main() {
String destinationPath = '/some/test/location';
// Copy the golden input and let the test run in an isolated temporary in-memory file system.
copyDirectorySync(
new LocalFileSystem().directory(path.join(dataPath, 'changed_sdk_location')),
new LocalFileSystem().directory(fs.path.join(dataPath, 'changed_sdk_location')),
fs.directory(destinationPath));
fs.currentDirectory = destinationPath;
......
......@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
......@@ -20,8 +19,8 @@ import 'src/context.dart';
import 'src/mocks.dart';
void main() {
final String filePath = path.join('bar', 'foo.txt');
final String filePath2 = path.join('foo', 'bar.txt');
final String filePath = fs.path.join('bar', 'foo.txt');
final String filePath2 = fs.path.join('foo', 'bar.txt');
Directory tempDir;
String basePath;
DevFS devFS;
......@@ -68,7 +67,7 @@ void main() {
testUsingContext('create dev file system', () async {
// simulate workspace
File file = fs.file(path.join(basePath, filePath));
File file = fs.file(fs.path.join(basePath, filePath));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3]);
......@@ -83,25 +82,25 @@ void main() {
int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test .packages',
'writeFile test ${path.join('bar', 'foo.txt')}',
'writeFile test ${path.join('packages', 'somepkg', 'somefile.txt')}',
'writeFile test ${fs.path.join('bar', 'foo.txt')}',
'writeFile test ${fs.path.join('packages', 'somepkg', 'somefile.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 31);
});
testUsingContext('add new file to local file system', () async {
File file = fs.file(path.join(basePath, filePath2));
File file = fs.file(fs.path.join(basePath, filePath2));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]);
int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test ${path.join('foo', 'bar.txt')}',
'writeFile test ${fs.path.join('foo', 'bar.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 7);
});
testUsingContext('modify existing file on local file system', () async {
File file = fs.file(path.join(basePath, filePath));
File file = fs.file(fs.path.join(basePath, filePath));
// Set the last modified time to 5 seconds in the past.
updateFileModificationTime(file.path, new DateTime.now(), -5);
int bytes = await devFS.update();
......@@ -112,17 +111,17 @@ void main() {
await file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test ${path.join('bar', 'foo.txt')}',
'writeFile test ${fs.path.join('bar', 'foo.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 6);
}, skip: io.Platform.isWindows); // TODO(goderbauer): enable when updateFileModificationTime is ported to Windows
testUsingContext('delete a file from the local file system', () async {
File file = fs.file(path.join(basePath, filePath));
File file = fs.file(fs.path.join(basePath, filePath));
await file.delete();
int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'deleteFile test ${path.join('bar', 'foo.txt')}',
'deleteFile test ${fs.path.join('bar', 'foo.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 0);
......@@ -132,7 +131,7 @@ void main() {
int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test .packages',
'writeFile test ${path.join('packages', 'newpkg', 'anotherfile.txt')}',
'writeFile test ${fs.path.join('packages', 'newpkg', 'anotherfile.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 51);
......@@ -217,7 +216,7 @@ void main() {
testUsingContext('create dev file system', () async {
// simulate workspace
File file = fs.file(path.join(basePath, filePath));
File file = fs.file(fs.path.join(basePath, filePath));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3]);
......@@ -232,8 +231,8 @@ void main() {
int bytes = await devFS.update();
vmService.expectMessages(<String>[
'writeFile test .packages',
'writeFile test ${path.join('bar', 'foo.txt')}',
'writeFile test ${path.join('packages', 'somepkg', 'somefile.txt')}',
'writeFile test ${fs.path.join('bar', 'foo.txt')}',
'writeFile test ${fs.path.join('packages', 'somepkg', 'somefile.txt')}',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 31);
......@@ -329,16 +328,16 @@ void _cleanupTempDirs() {
Future<Null> _createPackage(String pkgName, String pkgFileName) async {
final Directory pkgTempDir = _newTempDir();
File pkgFile = fs.file(path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName));
File pkgFile = fs.file(fs.path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName));
await pkgFile.parent.create(recursive: true);
pkgFile.writeAsBytesSync(<int>[11, 12, 13]);
_packages[pkgName] = pkgTempDir;
StringBuffer sb = new StringBuffer();
_packages.forEach((String pkgName, Directory pkgTempDir) {
Uri pkgPath = path.toUri(path.join(pkgTempDir.path, pkgName, 'lib'));
Uri pkgPath = fs.path.toUri(fs.path.join(pkgTempDir.path, pkgName, 'lib'));
sb.writeln('$pkgName:$pkgPath');
});
fs.file(path.join(_tempDirs[0].path, '.packages')).writeAsStringSync(sb.toString());
fs.file(fs.path.join(_tempDirs[0].path, '.packages')).writeAsStringSync(sb.toString());
}
String _inAssetBuildDirectory(String filename) => path.join(getAssetBuildDirectory(), filename);
\ No newline at end of file
String _inAssetBuildDirectory(String filename) => fs.path.join(getAssetBuildDirectory(), filename);
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:path/path.dart' as path;
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:test/test.dart';
......@@ -31,7 +31,7 @@ class IntelliJValidatorTestTarget extends IntelliJValidator {
IntelliJValidatorTestTarget(String title) : super(title);
@override
String get pluginsPath => path.join('test', 'data', 'intellij', 'plugins');
String get pluginsPath => fs.path.join('test', 'data', 'intellij', 'plugins');
@override
String get version => 'test.test.test';
......
......@@ -4,14 +4,13 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
setUp(() {
String flutterTools = path.join(platform.environment['FLUTTER_ROOT'],
String flutterTools = fs.path.join(platform.environment['FLUTTER_ROOT'],
'packages', 'flutter_tools');
assert(path.equals(fs.currentDirectory.path, flutterTools));
assert(fs.path.equals(fs.currentDirectory.path, flutterTools));
});
test('no unauthorized imports of dart:io', () {
......@@ -38,6 +37,6 @@ bool _isDartFile(FileSystemEntity entity) =>
entity is File && entity.path.endsWith('.dart');
bool _isNotWhitelisted(FileSystemEntity entity) =>
entity.path != path.join('lib', 'src', 'base', 'io.dart');
entity.path != fs.path.join('lib', 'src', 'base', 'io.dart');
File _asFile(FileSystemEntity entity) => entity;
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:test/test.dart';
void main() {
setUp(() {
String flutterTools = fs.path.join(platform.environment['FLUTTER_ROOT'],
'packages', 'flutter_tools');
assert(fs.path.equals(fs.currentDirectory.path, flutterTools));
});
test('no unauthorized imports of package:path', () {
for (String path in <String>['lib', 'bin', 'test']) {
fs.directory(path)
.listSync(recursive: true)
.where(_isDartFile)
.map(_asFile)
.forEach((File file) {
for (String line in file.readAsLinesSync()) {
if (line.startsWith(new RegExp('import.*package:path/path.dart'))) {
fail("${file.path} imports 'package:path/path.dart'; use 'fs.path' instead");
}
}
}
);
}
});
}
bool _isDartFile(FileSystemEntity entity) => entity is File && entity.path.endsWith('.dart');
File _asFile(FileSystemEntity entity) => entity;
......@@ -9,7 +9,6 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/commands/format.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
......@@ -38,7 +37,7 @@ void main() {
testUsingContext('a file', () async {
await createProject();
File srcFile = fs.file(path.join(temp.path, 'lib', 'main.dart'));
File srcFile = fs.file(fs.path.join(temp.path, 'lib', 'main.dart'));
String original = srcFile.readAsStringSync();
srcFile.writeAsStringSync(original.replaceFirst('main()', 'main( )'));
......
......@@ -5,7 +5,6 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -23,7 +22,7 @@ void main() {
});
testUsingContext('makeExecutable', () async {
File file = fs.file(path.join(temp.path, 'foo.script'));
File file = fs.file(fs.path.join(temp.path, 'foo.script'));
file.writeAsStringSync('hello world');
os.makeExecutable(file);
......
......@@ -21,7 +21,6 @@ import 'package:flutter_tools/src/toolchain.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:mockito/mockito.dart';
import 'package:path/path.dart' as path;
import 'package:process/process.dart';
import 'package:test/test.dart';
......@@ -70,9 +69,9 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext.putIfAbsent(SimControl, () => new MockSimControl());
testContext.putIfAbsent(Usage, () => new MockUsage());
final String basePath = path.dirname(path.fromUri(platform.script));
final String basePath = fs.path.dirname(fs.path.fromUri(platform.script));
final String flutterRoot =
path.normalize(path.join(basePath, '..', '..', '..'));
fs.path.normalize(fs.path.join(basePath, '..', '..', '..'));
try {
return await testContext.runInZone(() {
// Apply the overrides to the test context in the zone since their
......
......@@ -9,7 +9,6 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -18,8 +17,8 @@ import 'src/context.dart';
void main() {
group('test', () {
final String automatedTestsDirectory = path.join('..', '..', 'dev', 'automated_tests');
final String flutterTestDirectory = path.join(automatedTestsDirectory, 'flutter_test');
final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests');
final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test');
testUsingContext('TestAsyncUtils guarded function test', () async {
Cache.flutterRoot = '../..';
......@@ -30,7 +29,7 @@ void main() {
return _testFile('test_async_utils_unguarded', 1, automatedTestsDirectory, flutterTestDirectory);
});
testUsingContext('Missing flutter_test dependency', () async {
final String missingDependencyTests = path.join('..', '..', 'dev', 'missing_dependency_tests');
final String missingDependencyTests = fs.path.join('..', '..', 'dev', 'missing_dependency_tests');
Cache.flutterRoot = '../..';
return _testFile('trivial', 1, missingDependencyTests, missingDependencyTests);
});
......@@ -38,16 +37,16 @@ void main() {
}
Future<Null> _testFile(String testName, int wantedExitCode, String workingDirectory, String testDirectory) async {
final String fullTestName = path.join(testDirectory, '${testName}_test.dart');
final String fullTestName = fs.path.join(testDirectory, '${testName}_test.dart');
final File testFile = fs.file(fullTestName);
expect(testFile.existsSync(), true);
final String fullTestExpectation = path.join(testDirectory, '${testName}_expectation.txt');
final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt');
final File expectationFile = fs.file(fullTestExpectation);
expect(expectationFile.existsSync(), true);
final ProcessResult exec = await Process.run(
path.join(dartSdkPath, 'bin', 'dart'),
fs.path.join(dartSdkPath, 'bin', 'dart'),
<String>[
path.absolute(path.join('bin', 'flutter_tools.dart')),
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
'test',
'--no-color',
fullTestName
......
......@@ -6,7 +6,6 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/toolchain.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/context.dart';
......@@ -21,11 +20,11 @@ void main() {
expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
endsWith(path.join('cache', 'artifacts', 'engine', 'android-arm'))
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm'))
);
expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.release).path,
endsWith(path.join('cache', 'artifacts', 'engine', 'android-arm-release'))
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm-release'))
);
expect(tempDir, isNotNull);
tempDir.deleteSync(recursive: true);
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/commands/upgrade.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'src/common.dart';
......@@ -58,11 +57,11 @@ void main() {
String proj = temp.path;
expect(findProjectRoot(proj), proj);
expect(findProjectRoot(path.join(proj, 'lib')), proj);
expect(findProjectRoot(fs.path.join(proj, 'lib')), proj);
String hello = path.join(Cache.flutterRoot, 'examples', 'hello_world');
String hello = fs.path.join(Cache.flutterRoot, 'examples', 'hello_world');
expect(findProjectRoot(hello), hello);
expect(findProjectRoot(path.join(hello, 'lib')), hello);
expect(findProjectRoot(fs.path.join(hello, 'lib')), hello);
});
testUsingContext('outside project', () async {
......
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