-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathutils.dart
49 lines (46 loc) · 1018 Bytes
/
utils.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'dart:io';
String normalize(String path) {
if (Platform.isWindows) {
return path.replaceAll("/", "\\");
}
return path;
}
dynamic mkDir(String path, {bool logs = false}) {
try {
final file = Directory(path);
final check = file.existsSync();
if (logs) {
print('path: $path');
print('check: $check');
}
if (!check) {
return file.createSync();
}
return check;
} catch (e) {
throw e;
}
}
// Doesn't work wasted loads of time
void setEnv(String key, String value) {
if (Platform.isWindows) {
final result = Process.runSync(
"SET",
[key, "=", value, "&", "echo", "%$key%"],
// "\$env:$key=\"$value\"",
// [";", "\$env:$key"],
runInShell: true,
);
final resultA = Process.runSync(
"\$env:$key",
[],
runInShell: true,
);
print(resultA.stdout);
print(result.stdout);
print("ERROR");
print(result.stderr);
} else {
Process.runSync("export", ["$key=$value"]);
}
}