From f247397e7f1c893d99fb8d9908359b17ed386892 Mon Sep 17 00:00:00 2001 From: yukidaruma Date: Sun, 28 Jun 2020 02:35:02 +0900 Subject: [PATCH] Fix always fails to find "pubspec.lock" on Windows Use `Directory.current.path` instead of environmental variable `PWD` to support non-POSIX shell. --- bin/formats/about_libraries_format.dart | 3 +-- bin/formats/settings_bundle_plist_format.dart | 5 ++--- bin/main.dart | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/formats/about_libraries_format.dart b/bin/formats/about_libraries_format.dart index 05e601a..e52aa1b 100644 --- a/bin/formats/about_libraries_format.dart +++ b/bin/formats/about_libraries_format.dart @@ -50,9 +50,8 @@ class AboutLibrariesFormat extends FormatHoldable { /// Write formated text to file. @override void write() async { - Map environmentVars = Platform.environment; String directoryPath = - '${environmentVars["PWD"]}/android/app/src/main/res/values'; + '${Directory.current.path}/android/app/src/main/res/values'; String fullPath = "$directoryPath/license_strings.xml"; await new Directory(directoryPath).create(recursive: true); var output = """\ diff --git a/bin/formats/settings_bundle_plist_format.dart b/bin/formats/settings_bundle_plist_format.dart index ae90706..50335fa 100644 --- a/bin/formats/settings_bundle_plist_format.dart +++ b/bin/formats/settings_bundle_plist_format.dart @@ -51,9 +51,8 @@ class SettingsBundlePlistFormat extends FormatHoldable { /// Write formated text to file. @override void write() async { - Map environmentVars = Platform.environment; String directoryPath = - '${environmentVars["PWD"]}/ios/Runner/Settings.bundle'; + '${Directory.current.path}/ios/Runner/Settings.bundle'; if (FileSystemEntity.typeSync(directoryPath) == FileSystemEntityType.notFound) { throw AssertionError( @@ -83,7 +82,7 @@ ${rootOutput.join("\n")} doWrite(file, output); String subDirectoryPath = - '${environmentVars["PWD"]}/ios/Runner/Settings.bundle/com.ko2ic.dart-oss-licenses'; + '${Directory.current.path}/ios/Runner/Settings.bundle/com.ko2ic.dart-oss-licenses'; await new Directory(subDirectoryPath).create(recursive: true); tuples.forEach((tuple) { diff --git a/bin/main.dart b/bin/main.dart index b9d3d2e..cbd113f 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -66,8 +66,7 @@ main(List arguments) async { /// acquire all the names of the using library. Iterable findPluginNames() { - Map environmentVars = Platform.environment; - String path = '${environmentVars["PWD"]}/pubspec.lock'; + String path = '${Directory.current.path}/pubspec.lock'; if (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound) { throw AssertionError(