File

libs/nx/src/generators/library/updaters/update-package-json/update-package-json.ts

Index

Properties

Properties

scripts
Type Record<string | string>
import { Tree } from '@nx/devkit';
import { ProjectDetails } from '../../generator';

interface PackageJson {
  scripts: Record<string, string>;
}

export function updatePackageJson(tree: Tree, options: ProjectDetails) {
  const fileName = 'package.json';

  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  const packageJson = JSON.parse(tree.read(fileName)!.toString()) as PackageJson;

  const libraryFolderName = options.projectRoot.split('/').pop();

  packageJson.scripts ??= {};

  packageJson.scripts[
    `add-bb:${libraryFolderName}`
  ] = `npx nx generate @allianz/taly-nx:bb --project="${options.projectName}" --debug=false`;

  tree.write(fileName, JSON.stringify(packageJson, null, 2));
}

results matching ""

    No results matching ""