OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:path/path.dart'; | 5 import 'package:path/path.dart'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 import "dart:io"; | 7 import "dart:io"; |
8 | 8 |
9 main() { | 9 main() { |
10 if (Platform.operatingSystem != 'windows') return; | 10 if (Platform.operatingSystem != 'windows') return; |
11 var tempDir = Directory.systemTemp.createTempSync('dart_windows_environment'); | 11 var tempDir = Directory.systemTemp.createTempSync('dart_windows_environment'); |
12 var funkyDir = new Directory(join(tempDir.path, 'å')); | 12 var funkyDir = new Directory(join(tempDir.path, 'å')); |
13 funkyDir.createSync(); | 13 funkyDir.createSync(); |
14 var funkyFile = new File(join(funkyDir.path, 'funky.bat')); | 14 var funkyFile = new File(join(funkyDir.path, 'funky.bat')); |
15 funkyFile.writeAsStringSync(""" | 15 funkyFile.writeAsStringSync(""" |
16 @echo off | 16 @echo off |
17 set SCRIPTDIR=%~dp0 | 17 set SCRIPTDIR=%~dp0 |
18 %1 %2 | 18 %1 %2 |
19 """); | 19 """); |
20 var dart = Platform.executable; | 20 var dart = Platform.executable; |
21 var script = Platform.script | 21 var script = |
22 .resolve('windows_environment_script.dart') | 22 Platform.script.resolve('windows_environment_script.dart').toFilePath(); |
23 .toFilePath(); | 23 Process.run('cmd', ['/c', funkyFile.path, dart, script]).then((p) { |
24 Process.run('cmd', | |
25 ['/c', funkyFile.path, dart, script]).then((p) { | |
26 if (0 != p.exitCode) throw "Exit code not 0"; | 24 if (0 != p.exitCode) throw "Exit code not 0"; |
27 tempDir.deleteSync(recursive: true); | 25 tempDir.deleteSync(recursive: true); |
28 }); | 26 }); |
29 } | 27 } |
OLD | NEW |