Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: spawn ENAMETOOLONG #585

Open
Krinopotam opened this issue Nov 12, 2024 · 1 comment
Open

Error: spawn ENAMETOOLONG #585

Krinopotam opened this issue Nov 12, 2024 · 1 comment

Comments

@Krinopotam
Copy link

After updating to version 6.2.0, when I call the gh-pages --nojekyll -d deploy command, I get the following error:

Error: spawn ENAMETOOLONG
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at Object.spawn (node:child_process:761:9)
    at d:\projects\@krinopotam\ui-kit\node_modules\gh-pages\lib\git.js:30:22
    at new Promise (<anonymous>)
    at spawn (d:\projects\@krinopotam\ui-kit\node_modules\gh-pages\lib\git.js:29:10)
    at Git.exec (d:\projects\@krinopotam\ui-kit\node_modules\gh-pages\lib\git.js:69:10)
    at Git.rm (d:\projects\@krinopotam\ui-kit\node_modules\gh-pages\lib\git.js:146:15)
    at d:\projects\@krinopotam\ui-kit\node_modules\gh-pages\lib\index.js:180:22
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@darainfo
Copy link

darainfo commented Nov 14, 2024

It seems to be an error occurring on Windows.
I have temporarily resolved it by modifying the file as follows:

By replacing the Git.prototype.rm section in the node_modules\gh-pages\lib\git.js file with the code below, the issue is resolved.

const os = require('os');
/**
 * Remove all unversioned files.
 * @param {string | Array<string>} files Files argument.
 * @return {Promise} A promise.
 */
Git.prototype.rm = function (files) {
  if (!Array.isArray(files)) {
    files = [files];
  }

  if(os.platform() ==='win32'){
    return separateRm(this, files);
  } else{
    return this.exec('rm', '--ignore-unmatch', '-r', '-f', ...files);
  }
};

/**
 * files separate deletion
 * 
 * @param {Git} thisObj git
 * @param {Array} files files Files argument
 * @returns 
 */
async function separateRm (thisObj , files ) {

  const limitFileCount = 100;
  const fileLength = files.length;
  let loopCount = Math.ceil(fileLength /limitFileCount);

  let startIdx = 0;
  const allExecResult =[];
  let endIdx =limitFileCount; 
  for(let i =0;i <loopCount; i++){

    if(endIdx > fileLength){
      endIdx = fileLength-1;
    }

    let rmFiles = files.slice(startIdx, endIdx);
    allExecResult.push(await thisObj.exec('rm', '--ignore-unmatch', '-r', '-f', ...rmFiles));
    startIdx  = endIdx;
    endIdx = endIdx+ limitFileCount;
  }

  return allExecResult[allExecResult.length-1];
}

#586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants