diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart index 55164aff4b..ac5d5d69f5 100644 --- a/packages/flutter_tools/lib/src/android/android_sdk.dart +++ b/packages/flutter_tools/lib/src/android/android_sdk.dart @@ -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 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 platforms = []; // 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 buildTools = []; // 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 { } 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 diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index 4e2d941929..b9035bb7c3 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -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; } diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index 564beb6523..b5dc498c8a 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -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); } } diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index 39bfbec2ea..5c265ab070 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -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 manifestDescriptor = manifest; manifestDescriptor = manifestDescriptor['flutter'] ?? {}; - 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 _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 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 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 _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)) { diff --git a/packages/flutter_tools/lib/src/base/common.dart b/packages/flutter_tools/lib/src/base/common.dart index 6c7eca2bd6..e764e650eb 100644 --- a/packages/flutter_tools/lib/src/base/common.dart +++ b/packages/flutter_tools/lib/src/base/common.dart @@ -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; } diff --git a/packages/flutter_tools/lib/src/base/config.dart b/packages/flutter_tools/lib/src/base/config.dart index fb975a1999..7d38c2e5bf 100644 --- a/packages/flutter_tools/lib/src/base/config.dart +++ b/packages/flutter_tools/lib/src/base/config.dart @@ -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()); } diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart index e95eefe91b..4d295f0ff1 100644 --- a/packages/flutter_tools/lib/src/base/file_system.dart +++ b/packages/flutter_tools/lib/src/base/file_system.dart @@ -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()); diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart index 8c21a4c151..82fa562ca0 100644 --- a/packages/flutter_tools/lib/src/base/os.dart +++ b/packages/flutter_tools/lib/src/base/os.dart @@ -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; } diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart index 805d6a9b34..7fe223ba2e 100644 --- a/packages/flutter_tools/lib/src/base/utils.dart +++ b/packages/flutter_tools/lib/src/base/utils.dart @@ -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++; diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart index 76af12149c..2b3e697cd1 100644 --- a/packages/flutter_tools/lib/src/build_info.dart +++ b/packages/flutter_tools/lib/src/build_info.dart @@ -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'); } diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 6672612944..7b440746a3 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -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 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 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); } diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart index 8d2c3fab82..c31d0cb190 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_base.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart @@ -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 fileList) { if (fileList == null || fileList.isEmpty) - fileList = [path.current]; - String root = path.normalize(path.absolute(Cache.flutterRoot)); + fileList = [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; } diff --git a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart index 581afdab40..daccb390b5 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart @@ -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 = [fs.currentDirectory.path]; analysisTarget = fs.currentDirectory.path; @@ -157,9 +156,9 @@ class AnalysisServer { int _id = 0; Future 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 command = [ - path.join(dartSdkPath, 'bin', 'dart'), + fs.path.join(dartSdkPath, 'bin', 'dart'), snapshot, '--sdk', sdk, @@ -309,7 +308,7 @@ class AnalysisError implements Comparable { @override String toString() { - String relativePath = path.relative(file); + String relativePath = fs.path.relative(file); return '${severity.toLowerCase().padLeft(7)} • $message • $relativePath:$startLine:$startColumn'; } diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart index 846156cc7b..f0a8c50599 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_once.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart @@ -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 dartFiles = []; 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 flutterRootComponents; bool isFlutterLibrary(String filename) { - flutterRootComponents ??= path.normalize(path.absolute(Cache.flutterRoot)).split(path.separator); - List filenameComponents = path.normalize(path.absolute(filename)).split(path.separator); + flutterRootComponents ??= fs.path.normalize(fs.path.absolute(Cache.flutterRoot)).split(fs.path.separator); + List 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 _collectDartFiles(Directory dir, List 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 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; } } diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index 5ef7e3432b..17c1d89477 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -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 _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 _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 _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 filePaths = [ vmEntryPoints, @@ -186,14 +184,14 @@ Future _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([ 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([ snapshotDartIOS, ]); @@ -276,23 +274,23 @@ Future _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 commonBuildOptions = ['-arch', 'arm64', '-miphoneos-version-min=8.0']; if (interpreter) { - runCheckedSync(['mv', vmSnapshotData, path.join(outputDir.path, kVmSnapshotData)]); - runCheckedSync(['mv', isolateSnapshotData, path.join(outputDir.path, kIsolateSnapshotData)]); + runCheckedSync(['mv', vmSnapshotData, fs.path.join(outputDir.path, kVmSnapshotData)]); + runCheckedSync(['mv', isolateSnapshotData, fs.path.join(outputDir.path, kIsolateSnapshotData)]); runCheckedSync([ - 'xxd', '--include', kVmSnapshotData, path.basename(kVmSnapshotDataC) + 'xxd', '--include', kVmSnapshotData, fs.path.basename(kVmSnapshotDataC) ], workingDirectory: outputDir.path); runCheckedSync([ - 'xxd', '--include', kIsolateSnapshotData, path.basename(kIsolateSnapshotDataC) + 'xxd', '--include', kIsolateSnapshotData, fs.path.basename(kIsolateSnapshotDataC) ], workingDirectory: outputDir.path); runCheckedSync(['xcrun', 'cc'] @@ -307,7 +305,7 @@ Future _buildAotSnapshot( ..addAll(['-c', assembly, '-o', assemblyO])); } - String appSo = path.join(outputDir.path, 'app.dylib'); + String appSo = fs.path.join(outputDir.path, 'app.dylib'); List linkCommand = ['xcrun', 'clang'] ..addAll(commonBuildOptions) diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart index 7007c0390a..19b74d4c57 100644 --- a/packages/flutter_tools/lib/src/commands/build_apk.dart +++ b/packages/flutter_tools/lib/src/commands/build_apk.dart @@ -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 = [ - 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 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 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 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 buildApk( } Map _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 {}; @@ -649,7 +647,7 @@ Map _readBuildMeta(String buildDirectoryPath) { void _writeBuildMetaEntry(String buildDirectoryPath, String key, dynamic value) { Map 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)); } diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart index e562321a3c..5e3fc80029 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios.dart @@ -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( diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 83f3e7d0f0..4458ff98e9 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -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 templateContext = { '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; } diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 5e9156fa02..5d98854b3b 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -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 parts = path.split(appFile); + List 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( [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 _runTests(List 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 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( [dartVmPath]..addAll(args), environment: { 'VM_SERVICE_URL': observatoryUri } diff --git a/packages/flutter_tools/lib/src/commands/format.dart b/packages/flutter_tools/lib/src/commands/format.dart index 147d009916..45d8c047c6 100644 --- a/packages/flutter_tools/lib/src/commands/format.dart +++ b/packages/flutter_tools/lib/src/commands/format.dart @@ -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 cmd = [dartfmt, '-w']..addAll(argResults.rest); int result = await runCommandAndStreamOutput(cmd); if (result != 0) diff --git a/packages/flutter_tools/lib/src/commands/screenshot.dart b/packages/flutter_tools/lib/src/commands/screenshot.dart index 81b517d68b..9dd14b8512 100644 --- a/packages/flutter_tools/lib/src/commands/screenshot.dart +++ b/packages/flutter_tools/lib/src/commands/screenshot.dart @@ -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 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).'); } } diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 7178a78cb6..a86ad2eb75 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -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([ 'lcov', '--add-tracefile', baseCoverageData, @@ -173,7 +172,7 @@ class TestCommand extends FlutterCommand { testArgs.add('--'); Directory testDir; - Iterable files = argResults.rest.map((String testPath) => path.absolute(testPath)).toList(); + Iterable 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); diff --git a/packages/flutter_tools/lib/src/commands/trace.dart b/packages/flutter_tools/lib/src/commands/trace.dart index db011bf8c6..75edcc2aba 100644 --- a/packages/flutter_tools/lib/src/commands/trace.dart +++ b/packages/flutter_tools/lib/src/commands/trace.dart @@ -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 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. diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index bb8d761f54..2a3783b3d0 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -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 _downloadCoverageData() async { Status status = logger.startProgress("Downloading lcov data for package:flutter...", expectSlowOperation: true); final List 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(); diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart index 6d0ee9cd8d..73f7236ea7 100644 --- a/packages/flutter_tools/lib/src/commands/upgrade.dart +++ b/packages/flutter_tools/lib/src/commands/upgrade.dart @@ -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( [ - path.join(Cache.flutterRoot, 'bin', 'flutter'), '--no-color', 'precache' + fs.path.join(Cache.flutterRoot, 'bin', 'flutter'), '--no-color', 'precache' ], workingDirectory: Cache.flutterRoot, allowReentrantFlutter: true diff --git a/packages/flutter_tools/lib/src/dart/analysis.dart b/packages/flutter_tools/lib/src/dart/analysis.dart index 92b26108a7..a7430a7247 100644 --- a/packages/flutter_tools/lib/src/dart/analysis.dart +++ b/packages/flutter_tools/lib/src/dart/analysis.dart @@ -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 analyze(Iterable files) { @@ -74,7 +73,7 @@ class AnalysisDriver { List sources = []; 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) { diff --git a/packages/flutter_tools/lib/src/dart/dependencies.dart b/packages/flutter_tools/lib/src/dart/dependencies.dart index 04240ce034..5fb22c332f 100644 --- a/packages/flutter_tools/lib/src/dart/dependencies.dart +++ b/packages/flutter_tools/lib/src/dart/dependencies.dart @@ -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); } diff --git a/packages/flutter_tools/lib/src/dart/package_map.dart b/packages/flutter_tools/lib/src/dart/package_map.dart index 09bab8090f..e2b7ab0e16 100644 --- a/packages/flutter_tools/lib/src/dart/package_map.dart +++ b/packages/flutter_tools/lib/src/dart/package_map.dart @@ -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 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 diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 889652dc03..4cb0a7adfa 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -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 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 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( [sdkBinaryName('pub'), '--verbosity=warning', command, '--no-packages-dir', '--no-precompile'], diff --git a/packages/flutter_tools/lib/src/dart/sdk.dart b/packages/flutter_tools/lib/src/dart/sdk.dart index 150c260cb8..64f128d963 100644 --- a/packages/flutter_tools/lib/src/dart/sdk.dart +++ b/packages/flutter_tools/lib/src/dart/sdk.dart @@ -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)); } diff --git a/packages/flutter_tools/lib/src/dependency_checker.dart b/packages/flutter_tools/lib/src/dependency_checker.dart index fc58c425ec..b63a0d8e31 100644 --- a/packages/flutter_tools/lib/src/dependency_checker.dart +++ b/packages/flutter_tools/lib/src/dependency_checker.dart @@ -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 _dependencies = new Set(); @@ -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); } diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 4ddbdc1c1f..2cd8c09705 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -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 toRemove = new List(); _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 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: 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, diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 63272ba036..a7742f1b93 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -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 get installed { List validators = []; - List installPaths = ['/Applications', path.join(homeDirPath, 'Applications')]; + List installPaths = ['/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('', index); @@ -462,7 +461,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator { List 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'); } } diff --git a/packages/flutter_tools/lib/src/flx.dart b/packages/flutter_tools/lib/src/flx.dart index 9c4f22f11b..4d7e541d7a 100644 --- a/packages/flutter_tools/lib/src/flx.dart +++ b/packages/flutter_tools/lib/src/flx.dart @@ -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 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 assemble({ }) async { outputPath ??= defaultFlxOutputPath; workingDirPath ??= getAssetBuildDirectory(); - packagesPath ??= path.absolute(PackageMap.globalPackagesPath); + packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath); printTrace('Building $outputPath'); // Build the asset bundle. diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 3f04029cc0..fa229e0403 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -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 buildXcodeProject({ List 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([ - '-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 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 _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 _copyServiceFrameworks(List> 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 service in services) { String dylibPath = await getServiceFromUrl(service['ios-framework'], service['root'], service['name']); @@ -351,7 +350,7 @@ void _copyServiceDefinitionsManifest(List> 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 json = { 'services' : jsonServices }; manifest.writeAsStringSync(JSON.encode(json), mode: FileMode.WRITE, flush: true); diff --git a/packages/flutter_tools/lib/src/ios/plist_utils.dart b/packages/flutter_tools/lib/src/ios/plist_utils.dart index bee1b23d2a..2392468211 100644 --- a/packages/flutter_tools/lib/src/ios/plist_utils.dart +++ b/packages/flutter_tools/lib/src/ios/plist_utils.dart @@ -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([ diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index fcad6a7c0e..432f373835 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -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 _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([ - '--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 _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(['cp', localFile, path.join(simulatorHomeDirectory, targetFile)]); + runCheckedSync(['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 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 getScreenshots() { return new Set.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'); })); } diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 3d440e1983..16a0aecc15 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -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 getXcodeBuildSettings(String xcodeProjPath, String target) { - String absProjPath = path.absolute(xcodeProjPath); + String absProjPath = fs.path.absolute(xcodeProjPath); String out = runCheckedSync([ '/usr/bin/xcodebuild', '-project', absProjPath, '-target', target, '-showBuildSettings' ]); diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 32464f1870..235ccdcc40 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -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; } diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index b83cd81d3b..e4724299e9 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -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 _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 _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 = diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 78f2efbe13..1eeea2c70d 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -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 { 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 { // 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 { _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 { } 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 { 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 { 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 { /// Get all pub packages in the Flutter repo. List getRepoPackages() { - return _gatherProjectPaths(path.absolute(Cache.flutterRoot)) + return _gatherProjectPaths(fs.path.absolute(Cache.flutterRoot)) .map((String dir) => fs.directory(dir)) .toList(); } static List _gatherProjectPaths(String rootPath) { - if (fs.isFileSync(path.join(rootPath, '.dartignore'))) + if (fs.isFileSync(fs.path.join(rootPath, '.dartignore'))) return []; - if (fs.isFileSync(path.join(rootPath, 'pubspec.yaml'))) + if (fs.isFileSync(fs.path.join(rootPath, 'pubspec.yaml'))) return [rootPath]; return fs.directory(rootPath) @@ -312,15 +311,15 @@ class FlutterCommandRunner extends CommandRunner { /// Get the entry-points we want to analyze in the Flutter repo. List getRepoAnalysisEntryPoints() { - final String rootPath = path.absolute(Cache.flutterRoot); + final String rootPath = fs.path.absolute(Cache.flutterRoot); final List result = [ // 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((String path) => fs.directory(path)) ); return result; @@ -329,7 +328,7 @@ class FlutterCommandRunner extends CommandRunner { 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 { 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 { 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 { // 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; } diff --git a/packages/flutter_tools/lib/src/services.dart b/packages/flutter_tools/lib/src/services.dart index af3e6cc726..8df1392a95 100644 --- a/packages/flutter_tools/lib/src/services.dart +++ b/packages/flutter_tools/lib/src/services.dart @@ -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 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 json = { '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; } diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart index fc164a206d..958a688e18 100644 --- a/packages/flutter_tools/lib/src/template.dart +++ b/packages/flutter_tools/lib/src/template.dart @@ -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)); } diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index 8e5036899f..1c638854a1 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -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 reportOn = [path.join(packagePath, 'lib')]; + List reportOn = [fs.path.join(packagePath, 'lib')]; formatter = new LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath); } String result = await formatter.format(_globalHitmap); diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index ac2a3b138a..c812ee4090 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -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}"), )); diff --git a/packages/flutter_tools/lib/src/toolchain.dart b/packages/flutter_tools/lib/src/toolchain.dart index 53cb1d0ee9..f60c6e2b79 100644 --- a/packages/flutter_tools/lib/src/toolchain.dart +++ b/packages/flutter_tools/lib/src/toolchain.dart @@ -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'); } } diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index f1928b54ed..63632cfdd8 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -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 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()); diff --git a/packages/flutter_tools/lib/src/zip.dart b/packages/flutter_tools/lib/src/zip.dart index 788709e189..2b7a30002c 100644 --- a/packages/flutter_tools/lib/src/zip.dart +++ b/packages/flutter_tools/lib/src/zip.dart @@ -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((List 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((File value) { count -= 1; diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index 902a6630e9..e84cebf46c 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -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 diff --git a/packages/flutter_tools/test/all.dart b/packages/flutter_tools/test/all.dart index 3b2edf884b..f23d03f7e3 100644 --- a/packages/flutter_tools/test/all.dart +++ b/packages/flutter_tools/test/all.dart @@ -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(); diff --git a/packages/flutter_tools/test/analyze_continuously_test.dart b/packages/flutter_tools/test/analyze_continuously_test.dart index 22cbdac163..672df6073b 100644 --- a/packages/flutter_tools/test/analyze_continuously_test.dart +++ b/packages/flutter_tools/test/analyze_continuously_test.dart @@ -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() { diff --git a/packages/flutter_tools/test/analyze_duplicate_names_test.dart b/packages/flutter_tools/test/analyze_duplicate_names_test.dart index e5948fe508..81d434bfd0 100644 --- a/packages/flutter_tools/test/analyze_duplicate_names_test.dart +++ b/packages/flutter_tools/test/analyze_duplicate_names_test.dart @@ -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(); diff --git a/packages/flutter_tools/test/analyze_test.dart b/packages/flutter_tools/test/analyze_test.dart index cecd0467e7..e8ddc66e9a 100644 --- a/packages/flutter_tools/test/analyze_test.dart +++ b/packages/flutter_tools/test/analyze_test.dart @@ -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([tempDir.path]), isFalse); - expect(inRepo([path.join(tempDir.path, 'foo')]), isFalse); + expect(inRepo([fs.path.join(tempDir.path, 'foo')]), isFalse); expect(inRepo([Cache.flutterRoot]), isTrue); - expect(inRepo([path.join(Cache.flutterRoot, 'foo')]), isTrue); + expect(inRepo([fs.path.join(Cache.flutterRoot, 'foo')]), isTrue); // Relative paths String oldWorkingDirectory = fs.currentDirectory.path; try { diff --git a/packages/flutter_tools/test/android_sdk_test.dart b/packages/flutter_tools/test/android_sdk_test.dart index b2a20f0163..ebfbbf629b 100644 --- a/packages/flutter_tools/test/android_sdk_test.dart +++ b/packages/flutter_tools/test/android_sdk_test.dart @@ -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); } diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index 2e1f5f79d4..98409bf317 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart @@ -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)); diff --git a/packages/flutter_tools/test/config_test.dart b/packages/flutter_tools/test/config_test.dart index addf97b9fb..868dd3287e 100644 --- a/packages/flutter_tools/test/config_test.dart +++ b/packages/flutter_tools/test/config_test.dart @@ -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); }); diff --git a/packages/flutter_tools/test/create_test.dart b/packages/flutter_tools/test/create_test.dart index 5ff7b59a5a..ddff7801e2 100644 --- a/packages/flutter_tools/test/create_test.dart +++ b/packages/flutter_tools/test/create_test.dart @@ -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 _createAndAnalyzeProject(Directory dir, List 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', [flutterToolsPath, 'analyze'], workingDirectory: dir.path diff --git a/packages/flutter_tools/test/dart_dependencies_test.dart b/packages/flutter_tools/test/dart_dependencies_test.dart index 4f2079cf85..bdb47ba33a 100644 --- a/packages/flutter_tools/test/dart_dependencies_test.dart +++ b/packages/flutter_tools/test/dart_dependencies_test.dart @@ -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 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 { diff --git a/packages/flutter_tools/test/dependency_checker_test.dart b/packages/flutter_tools/test/dependency_checker_test.dart index 642c7d6fc8..115f25d4d3 100644 --- a/packages/flutter_tools/test/dependency_checker_test.dart +++ b/packages/flutter_tools/test/dependency_checker_test.dart @@ -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; diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index e4d5742226..477d7bb906 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart @@ -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([1, 2, 3]); @@ -83,25 +82,25 @@ void main() { int bytes = await devFS.update(); devFSOperations.expectMessages([ '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([1, 2, 3, 4, 5, 6, 7]); int bytes = await devFS.update(); devFSOperations.expectMessages([ - '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([1, 2, 3, 4, 5, 6]); bytes = await devFS.update(); devFSOperations.expectMessages([ - '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([ - '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([ '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([1, 2, 3]); @@ -232,8 +231,8 @@ void main() { int bytes = await devFS.update(); vmService.expectMessages([ '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 _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([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 diff --git a/packages/flutter_tools/test/doctor_test.dart b/packages/flutter_tools/test/doctor_test.dart index 61ffe9a00c..f84a6baabe 100644 --- a/packages/flutter_tools/test/doctor_test.dart +++ b/packages/flutter_tools/test/doctor_test.dart @@ -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'; diff --git a/packages/flutter_tools/test/forbid_dart_io_test.dart b/packages/flutter_tools/test/forbid_dart_io_test.dart index f079160c8f..cf7a9b5751 100644 --- a/packages/flutter_tools/test/forbid_dart_io_test.dart +++ b/packages/flutter_tools/test/forbid_dart_io_test.dart @@ -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; diff --git a/packages/flutter_tools/test/forbid_package_path_test.dart b/packages/flutter_tools/test/forbid_package_path_test.dart new file mode 100644 index 0000000000..6cb7c1e075 --- /dev/null +++ b/packages/flutter_tools/test/forbid_package_path_test.dart @@ -0,0 +1,36 @@ +// 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 ['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; diff --git a/packages/flutter_tools/test/format_test.dart b/packages/flutter_tools/test/format_test.dart index 8482c105f2..e2d7bbd0fa 100644 --- a/packages/flutter_tools/test/format_test.dart +++ b/packages/flutter_tools/test/format_test.dart @@ -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( )')); diff --git a/packages/flutter_tools/test/os_utils_test.dart b/packages/flutter_tools/test/os_utils_test.dart index 5d87be1687..43497bfa4d 100644 --- a/packages/flutter_tools/test/os_utils_test.dart +++ b/packages/flutter_tools/test/os_utils_test.dart @@ -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); diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 976f44ceab..c6b6087fff 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -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 diff --git a/packages/flutter_tools/test/test_test.dart b/packages/flutter_tools/test/test_test.dart index 76a2733cbc..3e27aebfd9 100644 --- a/packages/flutter_tools/test/test_test.dart +++ b/packages/flutter_tools/test/test_test.dart @@ -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 _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'), [ - path.absolute(path.join('bin', 'flutter_tools.dart')), + fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')), 'test', '--no-color', fullTestName diff --git a/packages/flutter_tools/test/toolchain_test.dart b/packages/flutter_tools/test/toolchain_test.dart index 90eaf418a2..10fc3341e0 100644 --- a/packages/flutter_tools/test/toolchain_test.dart +++ b/packages/flutter_tools/test/toolchain_test.dart @@ -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); diff --git a/packages/flutter_tools/test/upgrade_test.dart b/packages/flutter_tools/test/upgrade_test.dart index a33fd55388..b46e612c79 100644 --- a/packages/flutter_tools/test/upgrade_test.dart +++ b/packages/flutter_tools/test/upgrade_test.dart @@ -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 {