Skip to content

copyGitHooks fails on fresh install due to missing directory creation race condition #17123

@desig9stein

Description

@desig9stein

Description

On a fresh clone of the repository, running gulp copyGitHooks (or any npm script that triggers it) fails with the following error:

Error: ENOENT: no such file or directory, copyfile './.hooks/scripts/templates/default.js' -> './.git/hooks/scripts/templates/default.js'

  • igniteui-angular version: Master
  • browser: ALL

Root Cause(According to AI)
The copyGitHooks task in gulpfile.js attempts to create required directories using the asynchronous fs.mkdir, but does not wait for completion before calling fs.copyFileSync. This causes a race condition where the copy operation can occur before the directories exist, resulting in an ENOENT error.

Steps to Reproduce:

  1. Clone the repository fresh.
  2. Run npm install

Suggested Fix (According to AI):
Replace the asynchronous `fs.mkdir calls with synchronous fs.mkdirSync(dir, { recursive: true }) to ensure all directories exist before copying files.
Proposed code change:

dirs.forEach((dir) => {
    if (!fs.existsSync(dir)) {
        fs.mkdirSync(dir, { recursive: true });
    }
});

Expected result

The task should create all necessary directories before copying files, and not fail on a fresh install.

Attachments

Attach a sample if available, and screenshots, if applicable.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions