Unverified Commit 413475ac authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

Revert "Revert "fix recursiveCopy to preserve executable bit (#39505)" (#39588)" (#39594)

This reverts commit 61eab16c.
parent 61eab16c
......@@ -124,6 +124,11 @@ void recursiveCopy(Directory source, Directory target) {
else if (entity is File) {
final File dest = File(path.join(target.path, name));
dest.writeAsBytesSync(entity.readAsBytesSync());
// Preserve executable bit
final String modes = entity.statSync().modeString();
if (modes != null && modes.contains('x')) {
makeExecutable(dest);
}
}
}
}
......@@ -134,6 +139,27 @@ FileSystemEntity move(FileSystemEntity whatToMove,
.renameSync(path.join(to.path, name ?? path.basename(whatToMove.path)));
}
/// Equivalent of `chmod a+x file`
void makeExecutable(File file) {
// Windows files do not have an executable bit
if (Platform.isWindows) {
return;
}
final ProcessResult result = _processManager.runSync(<String>[
'chmod',
'a+x',
file.path,
]);
if (result.exitCode != 0) {
throw FileSystemException(
'Error making ${file.path} executable.\n'
'${result.stderr}',
file.path,
);
}
}
/// Equivalent of `mkdir directory`.
void mkdir(Directory directory) {
directory.createSync();
......
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