replica-bridge 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/bridge/install.js +17 -4
package/package.json
CHANGED
package/src/bridge/install.js
CHANGED
|
@@ -165,11 +165,24 @@ function serviceEnv() {
|
|
|
165
165
|
* The script the service runs. From npx (inside node_modules) a copy of this version is installed under
|
|
166
166
|
* ~/.config/replica-bridge/app, since npm may clear its npx cache; from a working copy, the working copy itself.
|
|
167
167
|
*/
|
|
168
|
-
function installedScript(say ) {
|
|
169
|
-
const
|
|
170
|
-
|
|
168
|
+
export function installedScript(say , current = process.argv[1] ? fs.realpathSync(process.argv[1]) : "") {
|
|
169
|
+
const parts = current.split(path.sep);
|
|
170
|
+
const at = parts.lastIndexOf("node_modules");
|
|
171
|
+
if (at < 0) return current;
|
|
171
172
|
const app = path.join(bridgeHome(), "app");
|
|
172
|
-
|
|
173
|
+
if (!process.env.REPLICA_BRIDGE_PACKAGE) {
|
|
174
|
+
// Copy what npx already installed (this package and its dependencies) rather than asking npm again: npx may have
|
|
175
|
+
// used a registry the second npm would not (`npx --registry`, or a company feed without this package).
|
|
176
|
+
const from = parts.slice(0, at + 1).join(path.sep);
|
|
177
|
+
say(`Copying replica-bridge ${PACKAGE_VERSION} to ${app}…`);
|
|
178
|
+
const next = `${app}.${process.pid}.part`;
|
|
179
|
+
fs.rmSync(next, { recursive: true, force: true });
|
|
180
|
+
fs.cpSync(from, path.join(next, "node_modules"), { recursive: true, dereference: true });
|
|
181
|
+
fs.rmSync(app, { recursive: true, force: true });
|
|
182
|
+
fs.renameSync(next, app);
|
|
183
|
+
return path.join(app, "node_modules", ...parts.slice(at + 1));
|
|
184
|
+
}
|
|
185
|
+
const spec = process.env.REPLICA_BRIDGE_PACKAGE;
|
|
173
186
|
say(`Installing ${spec} in ${app}…`);
|
|
174
187
|
fs.mkdirSync(app, { recursive: true });
|
|
175
188
|
// npx's own npm_* settings (a temporary prefix, for one) must not leak into this install.
|