Giter VIP home page Giter VIP logo

Comments (3)

Dutzu avatar Dutzu commented on May 27, 2024

I thought of 2 possible solutions:

  1. Since you already know you the packer you will use, you could narrow down the search and only look for the lock file specific to your packer.
    a. In my case the issue was clear: it found a location of a yarn.lock file and then tried to call npm run beforePackage on it.
  2. Instead of triggering the search multiple times for each individual lock file name, search only 1 time using all of them as valid options for a match.

Instead of:

const findUpIO = (name: string, directory = process.cwd()): IOO.IOOption<string> =>
  pipe(path.resolve(directory), (dir) =>
    pipe(
      safeFileExistsIO(path.join(dir, name)),
      IO.chain((exists: boolean) => {
        if (exists) return IOO.some(dir);
        if (isPathRoot(dir)) return IOO.none;
        return findUpIO(name, path.dirname(dir));
      })
    )
  );

/**
 * Forwards `rootDir` or finds project root folder.
 */
export const findProjectRoot = (rootDir?: string) =>
  pipe(
    IOO.fromNullable(rootDir),
    IOO.fold(() => findUpIO('yarn.lock'), IOO.of),
    IOO.fold(() => findUpIO('pnpm-lock.yaml'), IOO.of),
    IOO.fold(() => findUpIO('package-lock.json'), IOO.of),
    IOO.toUndefined
  )();

Have something like:

const findUpIO = (**names: string[]**, directory = process.cwd()): IOO.IOOption<string> =>
  pipe(path.resolve(directory), (dir) =>
    pipe(
      **array.some(names.map((name) => safeFileExistsIO(path.join(dir, name))))**,
      IO.chain((exists: boolean) => {
        if (exists) return IOO.some(dir);
        if (isPathRoot(dir)) return IOO.none;
        return findUpIO(name, path.dirname(dir));
      })
    )
  );

/**
 * Forwards `rootDir` or finds project root folder.
 */
export const findProjectRoot = (rootDir?: string) =>
  pipe(
    IOO.fromNullable(rootDir),
    IOO.fold(() => findUpIO(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json'), IOO.of),
    IOO.toUndefined
  )();

I know this is a crude solution, and I haven't given much thought and effort into how it would fit into the overall code, but perhaps it will help speed things up and shorten the time it takes to fix this.

from serverless-esbuild.

deanc avatar deanc commented on May 27, 2024

I can confirm this issue. We spent some time debugging it, and the cause was looking up the directory tree and finding a package-lock.json outside of the repo.

from serverless-esbuild.

github-actions avatar github-actions commented on May 27, 2024

🎉 This issue has been resolved in version 1.48.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

from serverless-esbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.