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

window Error: spawn ENAMETOOLONG error #586

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const cp = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const os = require('os');

/**
* @function Object() { [native code] }
Expand Down Expand Up @@ -143,9 +144,46 @@ Git.prototype.rm = function (files) {
if (!Array.isArray(files)) {
files = [files];
}
return this.exec('rm', '--ignore-unmatch', '-r', '-f', ...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];
}


/**
* Add files.
* @param {string | Array<string>} files Files argument.
Expand Down