UNPKG

1.44 kBSource Map (JSON)View Raw
1{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../../../modules/schematics/schematics-core/utility/package.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,uBAAuB,CACrC,IAAU,EACV,IAAY,EACZ,GAAW,EACX,OAAe;;IAEf,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,IAAM,UAAU,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,mCAAI,IAAI,CAAC;QACxE,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AArBD,0DAqBC","sourcesContent":["import { Tree } from '@angular-devkit/schematics';\n\n/**\n * Adds a package to the package.json\n */\nexport function addPackageToPackageJson(\n host: Tree,\n type: string,\n pkg: string,\n version: string\n): Tree {\n if (host.exists('package.json')) {\n const sourceText = host.read('package.json')?.toString('utf-8') ?? '{}';\n const json = JSON.parse(sourceText);\n if (!json[type]) {\n json[type] = {};\n }\n\n if (!json[type][pkg]) {\n json[type][pkg] = version;\n }\n\n host.overwrite('package.json', JSON.stringify(json, null, 2));\n }\n\n return host;\n}\n"]}
\No newline at end of file