MCPcopy Create free account
hub / github.com/nodejs/node / setupProject

Function setupProject

deps/npm/test/lib/commands/approve-scripts.js:10–49  ·  view source on GitHub ↗
({ allowScripts, withScripts = ['canvas'] } = {})

Source from the content-addressed store, hash-verified

8}
9
10const setupProject = ({ allowScripts, withScripts = ['canvas'] } = {}) => {
11 const pkg = {
12 name: 'host',
13 version: '1.0.0',
14 dependencies: Object.fromEntries(withScripts.map((n) => [n, '*'])),
15 }
16 if (allowScripts !== undefined) {
17 pkg.allowScripts = allowScripts
18 }
19
20 const lockPackages = { '': pkg }
21 const nodeModules = {}
22 for (const name of withScripts) {
23 const tarUrl = `https://registry.npmjs.org/${name}/-/${name}-1.0.0.tgz`
24 nodeModules[name] = {
25 'package.json': JSON.stringify({
26 name,
27 version: '1.0.0',
28 scripts: { install: 'echo install' },
29 }),
30 }
31 lockPackages[`node_modules/${name}`] = {
32 version: '1.0.0',
33 resolved: tarUrl,
34 hasInstallScript: true,
35 }
36 }
37
38 return {
39 'package.json': JSON.stringify(pkg, null, 2),
40 'package-lock.json': JSON.stringify({
41 name: pkg.name,
42 version: pkg.version,
43 lockfileVersion: 3,
44 requires: true,
45 packages: lockPackages,
46 }),
47 node_modules: nodeModules,
48 }
49}
50
51t.test('approve-scripts --pending lists unreviewed packages', async t => {
52 const { npm, joinedOutput } = await mockNpm(t, {

Callers 1

approve-scripts.jsFile · 0.70

Calls 1

mapMethod · 0.65

Tested by

no test coverage detected