A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/5a28a29799aac2c89b4e7a3d5c1d1d880346b743 below:

lazy load workspace dependency (#7352) · npm/cli@5a28a29 · GitHub

@@ -57,8 +57,10 @@ const loadLogFile = async (t, { buffer = [], mocks, testdir = {}, ...options } =

57 57

logFile,

58 58

LogFile,

59 59

readLogs: async () => {

60 -

const logDir = await fs.readdir(root)

61 -

const logFiles = logDir.map((f) => path.join(root, f))

60 +

const logDir = await fs.readdir(root, { withFileTypes: true })

61 +

const logFiles = logDir

62 +

.filter(f => f.isFile())

63 +

.map((f) => path.join(root, f.name))

62 64

.filter((f) => _fs.existsSync(f))

63 65

return Promise.all(logFiles.map(async (f) => {

64 66

const content = await fs.readFile(f, 'utf8')

@@ -202,6 +204,22 @@ t.test('cleans logs', async t => {

202 204

t.equal(logs.length, logsMax + 1)

203 205

})

204 206 207 +

t.test('cleans logs even when find folder inside logs folder', async t => {

208 +

const logsMax = 5

209 +

const { readLogs } = await loadLogFile(t, {

210 +

logsMax,

211 +

testdir: {

212 +

...makeOldLogs(10),

213 +

ignore_folder: {

214 +

'ignored-file.txt': 'hello',

215 +

},

216 +

},

217 +

})

218 + 219 +

const logs = await readLogs()

220 +

t.equal(logs.length, logsMax + 1)

221 +

})

222 + 205 223

t.test('doesnt clean current log by default', async t => {

206 224

const logsMax = 1

207 225

const { readLogs, logFile } = await loadLogFile(t, {

@@ -240,35 +258,6 @@ t.test('doesnt need to clean', async t => {

240 258

t.equal(logs.length, oldLogs + 1)

241 259

})

242 260 243 -

t.test('glob error', async t => {

244 -

const { readLogs } = await loadLogFile(t, {

245 -

logsMax: 5,

246 -

mocks: {

247 -

glob: { glob: () => {

248 -

throw new Error('bad glob')

249 -

} },

250 -

},

251 -

})

252 - 253 -

const logs = await readLogs()

254 -

t.equal(logs.length, 1)

255 -

t.match(last(logs).content, /error cleaning log files .* bad glob/)

256 -

})

257 - 258 -

t.test('do not log cleaning errors when logging is disabled', async t => {

259 -

const { readLogs } = await loadLogFile(t, {

260 -

logsMax: 0,

261 -

mocks: {

262 -

glob: () => {

263 -

throw new Error('should not be logged')

264 -

},

265 -

},

266 -

})

267 - 268 -

const logs = await readLogs()

269 -

t.equal(logs.length, 0)

270 -

})

271 - 272 261

t.test('cleans old style logs too', async t => {

273 262

const logsMax = 5

274 263

const oldLogs = 10

@@ -290,6 +279,7 @@ t.test('rimraf error', async t => {

290 279

testdir: makeOldLogs(oldLogs),

291 280

mocks: {

292 281

'fs/promises': {

282 +

readdir: fs.readdir,

293 283

rm: async (...args) => {

294 284

if (count >= 3) {

295 285

throw new Error('bad rimraf')


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4