formatPackageJson

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.package

This function simply take a package.json JSON formatted object and standardize some fields like the “author” one to be sure it is an object at the end, the “contributors” array the same way as the “author” one, etc… Here’s the list of processed actions:

  1. Transform the string version of the “author” field into an object with the properties “name”, “email” and “url”
  2. Transform the string version of the “contributors” field into an object with the properties “name”, “email” and “url”

Params

  1. json*-Object

    The json to process

Return

  1. -Object

    The standardized json

Example

import { formatPackageJson } from '@blackbyte/sugar/package';
formatPackageJson({
   "author": "Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)"
}); // => {
   "author": {
     "name": "Olivier Bossel",
     "email": "olivier.bossel@gmail.com",
     "url": "https://olivierbossel.com"
   }
}

Todo

  • testsnormal