10000 Turn off Electron asar archive support. by tgds · Pull Request #628 · shelljs/shelljs · GitHub
[go: up one dir, main page]

Skip to content

Turn off Electron asar archive support. #628

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

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
Turn off Electron asar archive support.
ShellJS fails to remove asar archives when run in Electron due to
Electron fs patches that treat asar archives as virtual directories.
See issue #618.
To overcome this, we set process.noAsar to true.
  • Loading branch information
Tomas Gajdos committed Dec 19, 2016
commit a7eb5c1daf2832e9d7de3d284391d1bd3381a92d
7 changes: 7 additions & 0 deletions src/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ function isWriteable(file) {
//@
//@ Removes files.
function _rm(options, files) {
// Switch Electron asar support off
// Prevents unexpected behaviour when attempting to remove an asar archive
var noAsar = process.noAsar;
process.noAsar = true;

if (!files) common.error('no paths given');

// Convert to array
Expand Down Expand Up @@ -141,6 +146,8 @@ function _rm(options, files) {
common.unlinkSync(file);
}
}); // forEach(file)

process.noAsar = noAsar;
return '';
} // rm
module.exports = _rm;
0