Skip to content

Commit

Permalink
fix(init.js): show a custom error when the submodule operation fails
Browse files Browse the repository at this point in the history
This generally occurs to people because they copy the executable in their project folder. Even
though it has an extension on Windows, git thinks it is already being used as a prefix. I think this
might relate to how git is installed w.r.t the new experimental symlink support. In any case, we
speculate the user have the executable in the wrong place and show a relevant error.

fix #57
  • Loading branch information
anacierdem committed Sep 23, 2022
1 parent 59f65f8 commit bd40a9f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions modules/actions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,25 @@ const autoVendor = async (info) => {
}

if (info.vendorStrategy === 'submodule') {
await runGitMaybeHost(info, [
'submodule',
'add',
'--force',
'--name',
LIBDRAGON_SUBMODULE,
'--branch',
LIBDRAGON_BRANCH,
LIBDRAGON_GIT,
info.vendorDirectory,
]);
try {
await runGitMaybeHost(info, [
'submodule',
'add',
'--force',
'--name',
LIBDRAGON_SUBMODULE,
'--branch',
LIBDRAGON_BRANCH,
LIBDRAGON_GIT,
info.vendorDirectory,
]);
} catch (e) {
if (!(e instanceof CommandError)) throw e;
// We speculate this is caused by the user, so replace it with a more useful error message.
e.message = `Unable to create submodule. If you have copied the executable in your project folder or you have a file named ${info.vendorDirectory}, removing it might solve this issue. Original error:\n${e.message}`;
throw e;
}

return info;
}

Expand Down

0 comments on commit bd40a9f

Please sign in to comment.