MCPcopy Index your code
hub / github.com/nodejs/node / runUpdateNotifier

Function runUpdateNotifier

deps/npm/test/lib/cli/update-notifier.js:53–124  ·  view source on GitHub ↗
(t, {
  STAT_ERROR,
  WRITE_ERROR,
  PACOTE_ERROR,
  PACOTE_MOCK_REQ_COUNT = 1,
  STAT_MTIME = 0,
  mocks: _mocks = {},
  command = 'help',
  prefixDir,
  version = CURRENT_VERSION,
  argv = [],
  wroteFile = false,
  ...config
} = {})

Source from the content-addressed store, hash-verified

51}
52
53const runUpdateNotifier = async (t, {
54 STAT_ERROR,
55 WRITE_ERROR,
56 PACOTE_ERROR,
57 PACOTE_MOCK_REQ_COUNT = 1,
58 STAT_MTIME = 0,
59 mocks: _mocks = {},
60 command = 'help',
61 prefixDir,
62 version = CURRENT_VERSION,
63 argv = [],
64 wroteFile = false,
65 ...config
66} = {}) => {
67 const mockFs = {
68 ...require('node:fs/promises'),
69 stat: async (path) => {
70 if (basename(path) !== '_update-notifier-last-checked') {
71 t.fail('no stat allowed for non update notifier files')
72 }
73 if (STAT_ERROR) {
74 throw STAT_ERROR
75 }
76 return { mtime: new Date(STAT_MTIME) }
77 },
78 writeFile: async (path, content) => {
79 wroteFile = true
80 if (content !== '') {
81 t.fail('no write file content allowed')
82 }
83 if (basename(path) !== '_update-notifier-last-checked') {
84 t.fail('no writefile allowed for non update notifier files')
85 }
86 if (WRITE_ERROR) {
87 throw WRITE_ERROR
88 }
89 },
90 }
91
92 const mocks = {
93 'node:fs/promises': mockFs,
94 '{ROOT}/package.json': { version },
95 'ci-info': { isCI: false, name: null },
96 ..._mocks,
97 }
98
99 const mock = await mockNpm(t, {
100 command,
101 mocks,
102 config,
103 exec: true,
104 prefixDir,
105 argv,
106 })
107 const registry = new MockRegistry({
108 tap: t,
109 registry: mock.npm.config.get('registry'),
110 })

Callers 1

update-notifier.jsFile · 0.85

Calls 9

basenameFunction · 0.85
tmockFunction · 0.85
updateNotifierFunction · 0.85
replyMethod · 0.80
timesMethod · 0.80
getMethod · 0.65
requireFunction · 0.50
mockNpmFunction · 0.50
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…