Running within Node script?
Closed this issue · 2 comments
mattfelten commented
What I'm trying to do is loop through the returned object to do some data manipulation to it, so I decided to try running this as a Node script.
I see the example in the readme of
const DependencyReport = require('@segment/dependency-report')
const report = new DependencyReport({
files: '**/*.js'
})
If I console.log( report );
that, I get
DependencyReport {
files: '**/*.js',
exportNames: [],
excludeGlob: '!**/node_modules/**' }
So I'm not sure how to actually generate the data. Adding options to that, such as
const report = new DependencyReport({
files: '**/*.js',
packages: 'react'
})
Doesn't seem to change the console.log at all.
If I try const report = new DependencyReport({ ... }).run()
, I get a permission denied error.
Promise { <pending> }
glob error { [Error: EACCES: permission denied, scandir '/Library/Application Support/ApplePushService']
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/Library/Application Support/ApplePushService' }
(node:17104) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, scandir '/Library/Application Support/ApplePushService'
(node:17104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:17104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
How do you recommend we use this package within a Node script?
danoc commented
It seems that files
needs to be an array:
Try changing files: '**/*.js'
to files: ['**/*.js']
and it should work.
mattfelten commented
Thanks!