Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make entrypoint executable on unix when sidekick is executed on windows #23

Merged
merged 3 commits into from
Mar 11, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions sidekick/lib/src/init/init_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,24 @@ void upgradeSidekickDependencies(

/// Makes a file executable 'rwxr-xr-x' (755)
Future<void> makeExecutable(FileSystemEntity file) async {
if (Platform.isWindows) {
// TODO can this be somehow encoded into the file so that windows users
// can generate it and unix users can execute it right away?
return;
}
if (file is Directory) {
throw "Can't make a Directory executable ($file)";
}
if (Platform.isWindows) {
// The windows file system works differently than unix based ones. exe files are automatically executable
// But when generating sidekick on windows, it should also be executable on unix systems on checkout.
// This is done by telling git about the file being executable.
// https://www.scivision.dev/git-windows-chmod-executable/
final p = await Process.start(
'git',
['update-index', '--chmod=+x', '--add', file.path],
);
final exitCode = await p.exitCode;
if (exitCode != 0) {
throw 'Cloud not set git file permission for unix systems for file ${file.path}';
passsy marked this conversation as resolved.
Show resolved Hide resolved
}
return;
}
if (!file.existsSync()) {
throw 'File not found ${file.path}';
}
Expand Down