From 390b804ca0de797ad4b3bf34bad57b2c572a5813 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 25 Sep 2014 21:49:28 +0800 Subject: [PATCH] Make process.dlopen work for asar packages. --- atom/common/lib/asar.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index f3f9fc6a..98e30535 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -220,3 +220,16 @@ fs.readdirSync = (p) -> throw createNotFoundError(asarPath, filePath) unless files files + +dlopen = process.dlopen +require('module')._extensions['.node'] = process.dlopen = (module, p) -> + [isAsar, asarPath, filePath] = splitPath p + return dlopen.apply this, arguments unless isAsar + + archive = getOrCreateArchive asarPath + throw new Error("Invalid package #{asarPath}") unless archive + + newPath = archive.copyFileOut filePath + throw createNotFoundError(asarPath, filePath) unless newPath + + dlopen module, newPath -- 2.43.0