Skip to content

Commit 1bc7588

Browse files
mzacharrnjudge
authored andcommitted
Added copyright info for NPM packages
Copyrights are extracted by checking if common licensing file names exists in the package and if they are found the content is then returned. As the scanning is split between container and host (due to the jq tool availability) the package path is left trimmed to remove first '/' - effectively converting it to relative path which can then be resolved correctly from the current working directory of host command. More license files to check can be added in the future by extending the "files" variable Resolves: #958 Signed-off-by: Matej Zachar <[email protected]>
1 parent 90297ef commit 1bc7588

File tree

1 file changed

+11
-0
lines changed
  • tern/analyze/default/command_lib

1 file changed

+11
-0
lines changed

tern/analyze/default/command_lib/base.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@ npm:
421421
host:
422422
- "jq -r '.. | objects | select(has(\"name\") and has(\"version\")) | .repository | if type == \"string\" then . else .url end | . // \"Unknown\"' npm-global.json"
423423
delimiter: "\n"
424+
copyrights:
425+
invoke:
426+
1:
427+
container:
428+
- "npm list -g --json --long --depth=1000 > npm-global.json"
429+
2:
430+
host:
431+
- "paths=`jq -r '.. | objects | select(has(\"name\") and has(\"version\")) | .path // \"Unknown\" | ltrimstr(\"/\")' npm-global.json`"
432+
- "files=\"license license.md LICENSE LICENSE.md copying copying.md COPYING COPYING.md\""
433+
- "for p in $paths; do for f in $files; do if [ -f $p/$f ]; then cat $p/$f; break; fi done; echo \"LICF\"; done"
434+
delimiter: "LICF"
424435
# golang----------------------------------------------------------------------
425436
go:
426437
pkg_format: ''

0 commit comments

Comments
 (0)