Skip to content

Commit

Permalink
fix(vcpkg): Use workaround for MODULE_NOT_FOUND error (#187)
Browse files Browse the repository at this point in the history
* fix(vcpkg): Use workaround for MODULE_NOT_FOUND error

* changelog
  • Loading branch information
jcs090218 authored Sep 15, 2023
1 parent d0d1f3c commit a41142d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* Add option to init from elisp source file (#183)
* Print archives progress (#184)
* Respect package file path in `autoload` command (44c042445bba0dd071d9112e58549437b7ebd58d)
* fix(vcpkg): Use workaround for `MODULE_NOT_FOUND` error (#187)

## 0.8.x
> Released Mar 08, 2023
Expand Down
35 changes: 34 additions & 1 deletion cmds/core/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function startCommand(commands, count) {
let command = commands[count];

console.log('[RUN]: ' + command);
let proc = child_process.spawn(command, { stdio: 'inherit', shell: true });

let proc = spawn(command, { stdio: 'inherit', shell: true });

proc.on('close', function (code) {
if (code == 0) {
Expand All @@ -75,3 +76,35 @@ function startCommand(commands, count) {
process.exit(code);
});
}

/**
* Spawn process to avoid `MODULE_NOT_FOUND` not found error,
* see https://github.com/vercel/pkg/issues/1356.
*
* @param { String } command - Command string.
* @param { JSON } options - Process options.
* @return Process object.
*/
function spawn(command, options) {
if (IS_PKG && command.includes('eask ')) {
let cmds = command.split(' ');
cmds = replaceEaskExec(cmds);
return child_process.spawn(process.execPath, cmds, options);
}
return child_process.spawn(command, options);
}

/**
* Replace all possible eask/cli executable to snapshot executable.
* @param { Array } cmds - Command array.
* @return Return updated command array.
*/
function replaceEaskExec(cmds) {
if (!IS_PKG) return;
for (let index = 0; index < cmds.length; ++index) {
if (cmds[index] == "eask") {
cmds[index] = process.argv[1]; // XXX: This is `/snapshot/cli/eask`
}
}
return cmds;
}
5 changes: 5 additions & 0 deletions lisp/core/run.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
(defun eask--export-command (command)
"Export COMMAND instruction."
(ignore-errors (make-directory eask-homedir t)) ; generate dir `~/.eask/'
;; XXX: Due to `MODULE_NOT_FOUND` not found error from vcpkg,
;; see https://github.com/vercel/pkg/issues/1356.
;;
;; We must split up all commands!
(setq command (eask-s-replace " && " "\n" command))
(write-region (concat command "\n") nil eask--run-file t))

(defun eask--unmatched-scripts (scripts)
Expand Down

0 comments on commit a41142d

Please sign in to comment.