-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
229 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
var | ||
minimist = require('minimist'), | ||
checker = require('license-checker'), | ||
path = require('path'); | ||
|
||
function displayHelp() { | ||
console.log(' Usage'); | ||
console.log(' enact license [options] [<module>]'); | ||
console.log(); | ||
console.log(' Arguments'); | ||
console.log(' module Optional module path'); | ||
console.log(' (default: <current directory>'); | ||
console.log(); | ||
console.log(' Options'); | ||
console.log(' -h, --help Display help information'); | ||
console.log(); | ||
process.exit(0); | ||
} | ||
|
||
// The following modules reside in `enact-dev` but end up in production builds of apps | ||
const enactDevProdModules = [ | ||
'babel-core', | ||
'string.fromcodepoint', | ||
'string.prototype.codepointat', | ||
'whatwg-fetch', | ||
'object-assign', | ||
'promise' | ||
]; | ||
|
||
let output = {}; | ||
|
||
module.exports = function(args) { | ||
const opts = minimist(args, { | ||
boolean: ['h', 'help'], | ||
alias: {h:'help'} | ||
}); | ||
|
||
opts.help && displayHelp(); | ||
|
||
let modules = []; | ||
|
||
if (opts._.length) { | ||
modules = modules.concat(opts._); | ||
} else { | ||
modules = [...resolveModulePath(enactDevProdModules), '.']; | ||
} | ||
|
||
modules.forEach(package => { | ||
checker.init({ | ||
start: package | ||
}, function(err, json) { | ||
if (err) { | ||
console.warn(`Unable to process licenses for ${path}: `, err); | ||
} else { | ||
output = Object.assign(output, json); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
process.on('exit', () => { | ||
if (Object.keys(output).length) { | ||
console.log(output); | ||
} | ||
}); | ||
|
||
// Resolve module directories relative to `enact-dev` | ||
function resolveModulePath(modules) { | ||
return modules.map(mod => path.dirname(require.resolve(mod))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.