Comparing version 0.17.1-pre.3 to 0.17.1-pre.4
// Copyright © 2021 React Training LLC. All rights reserved. | ||
export declare function installMagicExports(sourceDir: string): Promise<void>; | ||
export declare function installMagicExports(dependencies: { | ||
[name: string]: string; | ||
}, filesDir: string): Promise<void>; |
28
magic.js
@@ -6,25 +6,23 @@ // Copyright © 2021 React Training LLC. All rights reserved. | ||
var fs = require('fs-extra'); | ||
var fse = require('fs-extra'); | ||
var path = require('path'); | ||
async function installMagicExports(sourceDir) { | ||
let installDir = path.resolve(findClosestNodeModulesDir("remix"), "remix"); | ||
await fs.copy(sourceDir, installDir); | ||
async function installMagicExports(dependencies, filesDir) { | ||
let remixDir = path.dirname(require.resolve("remix")); | ||
let packageJsonFile = path.resolve(remixDir, "package.json"); | ||
await fse.copy(filesDir, remixDir); | ||
await fse.writeJson(packageJsonFile, assignDependencies(await fse.readJson(packageJsonFile), dependencies), { | ||
spaces: 2 | ||
}); | ||
} | ||
function findClosestNodeModulesDir(packageName) { | ||
let dir = path.dirname(require.resolve(packageName)); | ||
while (path.basename(dir) !== "node_modules") { | ||
let prevDir = dir; | ||
dir = path.dirname(dir); | ||
if (prevDir === dir) { | ||
throw new Error("Cannot find node_modules dir"); | ||
} | ||
function assignDependencies(object, dependencies) { | ||
if (!object.dependencies) { | ||
object.dependencies = {}; | ||
} | ||
return dir; | ||
Object.assign(object.dependencies, dependencies); | ||
return object; | ||
} | ||
exports.installMagicExports = installMagicExports; |
{ | ||
"name": "remix", | ||
"description": "A framework for building better websites", | ||
"version": "0.17.1-pre.3", | ||
"version": "0.17.1-pre.4", | ||
"homepage": "https://remix.run", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2423
52
2