question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asarUnpack unpacks parent directory when file is specified

See original GitHub issue
  • node v6.9.1:
  • npm v4.0.5:
  • electron-builder v10.15.1:
  • Target Build: win (ia32, x64):
  • Building On: win x64:

When a relative path from the app directory is passed into the build.asarUnpack option, the parent directory is copied instead of the file itself.

Example:

In package.json:

"build": {
    "asarUnpack": [
      "res/file.json"
    ]
}

In the shell:

npm run dist -- --win --ia32
Output Directory:

dist\win-ia32-unpacked\resources\app.asar.unpacked\res\<all files and sub-directories in original app/res, including file.json>

Other Notes:

I’m using the two package.json method (even without any external dependencies) if that matters. I will try building this on macOS shortly and reporting back with my results.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aouerfellicommented, Jan 2, 2017

The logs look fine to me:

> @ dist C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer
> build "--win" "--ia32"

No native production dependencies
Packaging for win32 ia32 using electron 1.4.13 to dist\win-ia32-unpacked
  electron-builder Spawning C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\node_modules\7zip-bin-win\x64\7za.exe x -bd C:\Users\Ahmad Ouerfelli\.electron\electron-v1.4.13-w
in32-ia32.zip -oC:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\dist\win-ia32-unpacked +0ms

7-Zip (a) [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04

Scanning the drive for archives:
1 file, 44030471 bytes (42 MiB)

Extracting archive: C:\Users\Ahmad Ouerfelli\.electron\electron-v1.4.13-win32-ia32.zip
--
Path = C:\Users\Ahmad Ouerfelli\.electron\electron-v1.4.13-win32-ia32.zip
Type = zip
Physical Size = 44030471

Everything is Ok

Files: 74
Size:       108417432
Compressed: 44030471
  electron-builder C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\node_modules\7zip-bin-win\x64\7za.exe (10572) exited with code 0 +3s
  electron-builder Dev or extraneous dependencies:  +0ms
  electron-builder Found existing winCodeSign C:\Users\Ahmad Ouerfelli\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.5.0 +788ms
  electron-builder Executing C:\Users\Ahmad Ouerfelli\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.5.0\rcedit.exe C:\Users\Ahmad Ouerfelli\Documents\Personal\station
-timer\dist\win-ia32-unpacked\Station Timer.exe --set-version-string CompanyName Ahmad Ouerfelli --set-version-string FileDescription Station Timer --set-version-string ProductName St
ation Timer --set-version-string InternalName Station Timer --set-version-string LegalCopyright Copyright © 2017 Ahmad Ouerfelli --set-version-string OriginalFilename  --set-file-vers
ion 1.0.0 --set-product-version 1.0.0 --set-icon C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\build\icon.ico +0ms
Building zip
  electron-builder Spawning C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\node_modules\7zip-bin-win\x64\7za.exe a -bd -mm=Deflate C:\Users\Ahmad Ouerfelli\Documents\Person
al\station-timer\dist\Station Timer-1.0.0-ia32-win.zip win-ia32-unpacked +763ms

7-Zip (a) [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04

Scanning the drive:
7 folders, 77 files, 108369660 bytes (104 MiB)

Creating archive: C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\dist\Station Timer-1.0.0-ia32-win.zip

Items to compress: 84


Files read from disk: 77
Archive size: 42774627 bytes (41 MiB)
Everything is Ok
  electron-builder C:\Users\Ahmad Ouerfelli\Documents\Personal\station-timer\node_modules\7zip-bin-win\x64\7za.exe (9032) exited with code 0 +8s

Here is my development package.json:

{
  "scripts": {
    "start": "electron ./app",
    "dev": "nodemon --exec \"npm start\" -e \"js css html\"",
    "pack": "build --dir",
    "dist": "build",
    "postinstall": "install-app-deps"
  },
  "directories": {
    "app": "./app"
  },
  "build": {
    "appId": "com.aouerfelli.station-timer",
    "asarUnpack": [
      "res/strings.json"
    ],
    "win": {
      "target": [
        "zip"
      ]
    },
    "mac": {
      "category": "public.app-category.utilities",
      "target": [
        "dmg"
      ]
    },
    "linux": {
      "category": "Utility"
    }
  },
  "devDependencies": {
    "electron": "^1.4.13",
    "electron-builder": "^10.15.1",
    "nodemon": "^1.11.0"
  }
}
0reactions
andrewjaykellercommented, Jan 6, 2017

@develar thanks so much! this fixed my problem!! woo!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to externalise folder with electron? - Stack Overflow
In the electron-builder.json under the build section add "asarUnpack": [ ... your files or folders ].
Read more >
Common Configuration - electron-builder
asarUnpack Array<String> | String | “undefined” - A glob patterns relative to the app directory, which specifies which files to unpack when creating...
Read more >
Moving two specific files into its parent folder within multiple ...
To move any file named fileA.txt or fileB.txt to its immediate parent directory: find . -maxdepth 4 -type f -name 'file[AB].txt' -execdir mv ......
Read more >
paulcbetts/electron-packager NPM
A glob expression, when specified, unpacks the file with matching names to the app.asar.unpacked directory. asar-unpack-dir - String. Unpacks the dir to ...
Read more >
Renaming many files to their parent directory name [duplicate]
I want to recursively change many files named raw.tex to parent-directory-hw.tex . Is there a simple scripting solution to this problem?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found