Commit 1c43c4e2 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Bump package:file version to 1.0.0 (#7371)

parent 29a88cf8
...@@ -6,7 +6,7 @@ import 'dart:async'; ...@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:convert' show JsonEncoder; import 'dart:convert' show JsonEncoder;
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/io.dart'; import 'package:file/local.dart';
import 'package:flutter_driver/flutter_driver.dart'; import 'package:flutter_driver/flutter_driver.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test/test.dart'; import 'package:test/test.dart';
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/io.dart'; import 'package:file/local.dart';
import 'package:file/memory.dart';
/// The file system implementation used by this library. /// The file system implementation used by this library.
/// ///
......
...@@ -8,7 +8,7 @@ environment: ...@@ -8,7 +8,7 @@ environment:
sdk: '>=1.19.0 <2.0.0' sdk: '>=1.19.0 <2.0.0'
dependencies: dependencies:
file: '^0.1.0' file: '^1.0.0'
json_rpc_2: '^2.0.0' json_rpc_2: '^2.0.0'
matcher: '>=0.12.0 <1.0.0' matcher: '>=0.12.0 <1.0.0'
path: '^1.4.0' path: '^1.4.0'
......
...@@ -4,28 +4,19 @@ ...@@ -4,28 +4,19 @@
import 'dart:io' as dart_io; import 'dart:io' as dart_io;
import 'package:file/io.dart'; import 'package:file/file.dart';
import 'package:file/sync_io.dart'; import 'package:file/local.dart';
import 'package:file/memory.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
export 'package:file/io.dart'; export 'package:file/file.dart';
export 'package:file/sync_io.dart'; export 'package:file/local.dart';
/// Currently active implementation of the file system. /// Currently active implementation of the file system.
/// ///
/// By default it uses local disk-based implementation. Override this in tests /// By default it uses local disk-based implementation. Override this in tests
/// with [MemoryFileSystem]. /// with [MemoryFileSystem].
FileSystem fs = new LocalFileSystem(); FileSystem fs = new LocalFileSystem();
SyncFileSystem syncFs = new SyncLocalFileSystem();
typedef String CurrentDirectoryGetter();
final CurrentDirectoryGetter _defaultCurrentDirectoryGetter = () {
return dart_io.Directory.current.path;
};
/// Points to the current working directory (like `pwd`).
CurrentDirectoryGetter getCurrentDirectory = _defaultCurrentDirectoryGetter;
/// Exits the process with the given [exitCode]. /// Exits the process with the given [exitCode].
typedef void ExitFunction([int exitCode]); typedef void ExitFunction([int exitCode]);
...@@ -37,20 +28,19 @@ final ExitFunction _defaultExitFunction = ([int exitCode]) { ...@@ -37,20 +28,19 @@ final ExitFunction _defaultExitFunction = ([int exitCode]) {
/// Exits the process. /// Exits the process.
ExitFunction exit = _defaultExitFunction; ExitFunction exit = _defaultExitFunction;
/// Restores [fs] and [syncFs] to the default local disk-based implementation. /// Restores [fs] to the default local disk-based implementation.
void restoreFileSystem() { void restoreFileSystem() {
fs = new LocalFileSystem(); fs = new LocalFileSystem();
syncFs = new SyncLocalFileSystem();
getCurrentDirectory = _defaultCurrentDirectoryGetter;
exit = _defaultExitFunction; exit = _defaultExitFunction;
} }
/// Uses in-memory replacments for `dart:io` functionality. Useful in tests. /// Uses in-memory replacments for `dart:io` functionality. Useful in tests.
void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) { void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) {
MemoryFileSystem memFs = new MemoryFileSystem(); fs = new MemoryFileSystem();
fs = memFs; if (!fs.directory(cwd).existsSync()) {
syncFs = new SyncMemoryFileSystem(backedBy: memFs.storage); fs.directory(cwd).createSync(recursive: true);
getCurrentDirectory = () => cwd; }
fs.currentDirectory = cwd;
exit = exitFunction ?? ([int exitCode]) { exit = exitFunction ?? ([int exitCode]) {
throw new Exception('Exited with code $exitCode'); throw new Exception('Exited with code $exitCode');
}; };
...@@ -60,9 +50,9 @@ void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) { ...@@ -60,9 +50,9 @@ void useInMemoryFileSystem({ String cwd: '/', ExitFunction exitFunction }) {
void ensureDirectoryExists(String filePath) { void ensureDirectoryExists(String filePath) {
String dirPath = path.dirname(filePath); String dirPath = path.dirname(filePath);
if (syncFs.type(dirPath) == FileSystemEntityType.DIRECTORY) if (fs.typeSync(dirPath) == FileSystemEntityType.DIRECTORY)
return; return;
syncFs.directory(dirPath).create(recursive: true); fs.directory(dirPath).createSync(recursive: true);
} }
/// Recursively copies a folder from `srcPath` to `destPath` /// Recursively copies a folder from `srcPath` to `destPath`
......
...@@ -155,7 +155,7 @@ class DriveCommand extends RunCommandBase { ...@@ -155,7 +155,7 @@ class DriveCommand extends RunCommandBase {
String appFile = path.normalize(targetFile); String appFile = path.normalize(targetFile);
// This command extends `flutter start` and therefore CWD == package dir // This command extends `flutter start` and therefore CWD == package dir
String packageDir = getCurrentDirectory(); String packageDir = fs.currentDirectory.path;
// Make appFile path relative to package directory because we are looking // Make appFile path relative to package directory because we are looking
// for the corresponding test file relative to it. // for the corresponding test file relative to it.
......
...@@ -12,7 +12,7 @@ dependencies: ...@@ -12,7 +12,7 @@ dependencies:
args: ^0.13.4 args: ^0.13.4
coverage: ^0.8.0 coverage: ^0.8.0
crypto: '>=1.1.1 <3.0.0' crypto: '>=1.1.1 <3.0.0'
file: ^0.1.0 file: ^1.0.0
http: ^0.11.3 http: ^0.11.3
intl: '>=0.14.0 <0.15.0' intl: '>=0.14.0 <0.15.0'
json_rpc_2: ^2.0.0 json_rpc_2: ^2.0.0
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'package:file/file.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -34,6 +34,8 @@ void main() { ...@@ -34,6 +34,8 @@ void main() {
command = new DriveCommand(); command = new DriveCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
useInMemoryFileSystem(cwd: '/some/app'); useInMemoryFileSystem(cwd: '/some/app');
fs.directory('test').createSync();
fs.directory('test_driver').createSync();
targetDeviceFinder = () { targetDeviceFinder = () {
throw 'Unexpected call to targetDeviceFinder'; throw 'Unexpected call to targetDeviceFinder';
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment