How to use the @lerna/package.lazy function in @lerna/package

To help you get started, we’ve selected a few @lerna/package examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lerna / lerna / helpers / pkg-matchers / index.js View on Github external
function toHaveBinaryLinks(received, ...inputs) {
  const pkg = Package.lazy(received);
  const links =
    process.platform === "win32"
      ? inputs.reduce(
          (acc, input) => [
            ...acc,
            input,
            // cmd.exe
            [input, "cmd"].join("."),
            // powershell
            [input, "ps1"].join("."),
          ],
          []
        )
      : inputs;

  const expectedName = `expected ${pkg.name}`;
github lerna / lerna / utils / symlink-binary / symlink-binary.js View on Github external
function symlinkBinary(srcPackageRef, destPackageRef) {
  return Promise.all([Package.lazy(srcPackageRef), Package.lazy(destPackageRef)]).then(
    ([srcPackage, destPackage]) => {
      const actions = Object.keys(srcPackage.bin).map(name => {
        const srcLocation = srcPackage.contents
          ? path.resolve(srcPackage.location, srcPackage.contents)
          : srcPackage.location;
        const src = path.join(srcLocation, srcPackage.bin[name]);
        const dst = path.join(destPackage.binLocation, name);

        // Symlink all declared binaries, even if they don't exist (yet). We will
        // assume the package author knows what they're doing and that the binaries
        // will be generated during a later build phase (potentially source compiled from
        // another language).
        return { src, dst };
      });

      if (actions.length === 0) {
github lerna / lerna / helpers / pkg-matchers / index.js View on Github external
function toHaveExecutables(received, ...files) {
  const pkg = Package.lazy(received);

  const expectedFiles = `expected ${files.join(", ")}`;
  const expectedAction = "to be executable";
  const expectation = `${expectedFiles} ${expectedAction}`;

  // eslint-disable-next-line prefer-destructuring
  const X_OK = (fs.constants || fs).X_OK;
  const failed = files.filter(file => {
    try {
      return fs.accessSync(path.join(pkg.location, file), X_OK);
    } catch (_) {
      return true;
    }
  });

  const pass = failed.length === 0;
github lerna / lerna / helpers / pkg-matchers / index.js View on Github external
return (received, name, range, options) => {
    const pkg = Package.lazy(received);
    const noDeps = typeof pkg[dependencyType] !== "object";
    const id = [name, range].filter(Boolean).join("@");
    const exact = options && options.exact;

    const expectedName = `expected ${pkg.name}`;
    const expectedAction = `to ${verb} on ${id}`;
    const expectation = `${expectedName} ${expectedAction}`;
    const json = JSON.stringify(pkg[dependencyType], null, 2);

    if (noDeps) {
      return {
        message: () => `${expectation} but no ${dependencyType} specified`,
        pass: false,
      };
    }
github lerna / lerna / utils / pack-directory / lib / pack-directory.js View on Github external
function packDirectory(_pkg, dir, _opts) {
  const pkg = Package.lazy(_pkg, dir);
  const opts = PackConfig(_opts);

  opts.log.verbose("pack-directory", path.relative(".", pkg.contents));

  let chain = Promise.resolve();

  if (opts.ignorePrepublish !== true) {
    chain = chain.then(() => runLifecycle(pkg, "prepublish", opts));
  }

  chain = chain.then(() => runLifecycle(pkg, "prepare", opts));

  if (opts.lernaCommand === "publish") {
    chain = chain.then(() => pkg.refresh());
    chain = chain.then(() => runLifecycle(pkg, "prepublishOnly", opts));
    chain = chain.then(() => pkg.refresh());

@lerna/package

Lerna's internal representation of a package

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Popular @lerna/package functions