You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If node-tar is used in Electron environment where asar file support is enabled, the entry names with extension asar will not be written correctly, because Electron uses its own 'fs' library which handles asar files as a sub-directory.
Hence, Electron does offer 'original-fs' library if you want to use asar file as normal file instead of a virtual sub-directory in the modified 'fs'.
It would be good if node-tar supported the 'original-fs' library by demand instead of 'fs' from electron.
Either you could add an extra option for tar.x to use original-fs instead of fs library. In this case the user should import fs-original and append the reference to the options.
Or in the source in node-tar the electron could be detected:
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true;
}
If yes, import fs from 'node:fs' in your code should be import fs from 'original-fs'.
Or, I just found the easiest solution. In Electron I found process.noAsar = true
But this approach could be used outside the library, before e.g. the tar.x is called and afterwards this should be set to false again if needed.
Activity
isaacs commentedon Apr 10, 2024
I'm not sure what the feature request is here. What would the interface look like, and how would it behave?
dashart-ke commentedon Jun 11, 2024
I ran into a similar issue today:
In my electron based application, I tried to extract a tar.gz archive, which is contains an electron application.
After extraction, the following file:

ELECTRON_APP_NAME.app/Contents/Resources/app.asar
is missing in target directory:
The log (verbose) reports, it would extract 'app.asar':
...
Extracting: ELECTRON_APP_NAME.app/Contents/Resources/nb.lproj/
Extracting: ELECTRON_APP_NAME.app/Contents/Resources/app.asar
Extracting: ELECTRON_APP_NAME.app/Contents/Resources/am.lproj/
...
This looks like an internal side effect of special electron fs behavior, which will treat app.asar like a regular directory
https://www.electronjs.org/docs/latest/tutorial/asar-archives#treating-an-asar-archive-as-a-normal-file
isaacs commentedon Jun 13, 2024
@dashart-ke ok, so, same question I asked @markkovacs76: what do you want tar to do about it?
markkovacs76 commentedon Jun 13, 2024
Either you could add an extra option for tar.x to use original-fs instead of fs library. In this case the user should import fs-original and append the reference to the options.
Or in the source in node-tar the electron could be detected:
If yes,
import fs from 'node:fs'in your code should beimport fs from 'original-fs'.Or, I just found the easiest solution. In Electron I found
process.noAsar = trueBut this approach could be used outside the library, before e.g. the tar.x is called and afterwards this should be set to false again if needed.
isaacs commentedon Jun 13, 2024
So the feature request is to have a
fsoption, which defaults toimport * as fs from 'node:fs', that you can pass your ownfsimplementation into?Seems fine to me. Just a pain to go through and make the edits. But patch welcome.