From 0a718fd23405da00859c1630c3e121b604510214 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Wed, 2 Feb 2022 12:41:00 -0800 Subject: [PATCH] Remove NOASSERTION license --- ci/src/Foreign/Licensee.purs | 14 +++++++++----- ci/src/Registry/Scripts/LegacyImport/Manifest.purs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/src/Foreign/Licensee.purs b/ci/src/Foreign/Licensee.purs index 1aef96971..8d8852028 100644 --- a/ci/src/Foreign/Licensee.purs +++ b/ci/src/Foreign/Licensee.purs @@ -3,7 +3,7 @@ module Foreign.Licensee where import Registry.Prelude import Control.Parallel as Parallel -import Foreign.JsonRepair as JsonRepair +import Data.Array as Array import Foreign.Tmp as Tmp import Node.ChildProcess as NodeProcess import Node.FS.Aff as FS @@ -33,7 +33,7 @@ detect directory = do NodeProcess.Normally n | n == 0 || n == 1 -> do let parse :: String -> Either String (Array String) - parse str = Json.parseJson (JsonRepair.tryRepair str) >>= \json -> do + parse str = Json.parseJson str >>= \json -> do obj <- Json.decode json licenses <- obj .: "licenses" spdxIds <- traverse (_ .: "spdx_id") licenses @@ -46,7 +46,11 @@ detect directory = do log "arising from the result: " log result.stdout pure $ Left error - Right out -> - pure $ Right out - _ -> + Right out -> do + -- A NOASSERTION result means that a LICENSE file could not be parsed. + -- For the purposes of the registry we disregard this result, since + -- we retrieve the license via the package manifest(s) as well. + pure $ Right $ Array.filter (_ /= "NOASSERTION") out + _ -> do + log $ "Licensee process exited unexpectedly: " <> result.stderr pure $ Left result.stderr diff --git a/ci/src/Registry/Scripts/LegacyImport/Manifest.purs b/ci/src/Registry/Scripts/LegacyImport/Manifest.purs index 854c4cb0d..0526b8836 100644 --- a/ci/src/Registry/Scripts/LegacyImport/Manifest.purs +++ b/ci/src/Registry/Scripts/LegacyImport/Manifest.purs @@ -108,7 +108,7 @@ constructManifestFields package version address = do let spagoLicenses = maybe [] NEA.toArray $ _.license =<< hush spagoManifest bowerLicenses = maybe [] NEA.toArray $ _.license =<< hush bowerManifest - licenseeLicenses = Array.catMaybes $ map NES.fromString licenseeOutput + licenseeLicenses = Array.mapMaybe NES.fromString licenseeOutput license = NEA.fromArray $ Array.nub $ Array.concat [ licenseeLicenses, spagoLicenses, bowerLicenses ] description = join (_.description <$> hush bowerManifest)