clasp: .claspignore fails **/node_modules/**
Expected Behavior
**/node_modules/**
**/**
Ignores all files in node_modules .
Actual Behavior
follow-redirects options { protocol: 'https:',
maxRedirects: 21,
maxBodyLength: 10485760,
path: '/v1/projects/SCRUBBED/content',
method: 'put',
headers:
{ Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json;charset=utf-8',
Authorization: 'Bearer SCRUBBED',
'User-Agent': 'google-api-nodejs-client/1.3.1',
'Content-Length': 3879 },
agent: undefined,
auth: undefined,
hostname: 'script.googleapis.com',
port: null,
nativeProtocols:
{ 'http:':
{ _connectionListener: [Function: connectionListener],
METHODS: [Array],
STATUS_CODES: [Object],
Agent: [Object],
ClientRequest: [Object],
globalAgent: [Object],
IncomingMessage: [Object],
OutgoingMessage: [Object],
Server: [Object],
ServerResponse: [Object],
createServer: [Function: createServer],
get: [Function: get],
request: [Function: request] },
'https:':
{ Server: [Object],
createServer: [Function: createServer],
globalAgent: [Object],
Agent: [Object],
request: [Function: request],
get: [Function: get] } } } +0ms
Push failed. Errors:
Invalid value at 'files[2].type' (TYPE_ENUM), "D"
node_modules/fsevents/build/Release/.deps/Release/.node.d Is getting picked up with the following error.
Added logging to clasp produces:
{ name: 'node_modules/fsevents/build/Release/.deps/Release/.node.d' }
{ name: 'node_modules/fsevents/build/Release/.deps/Release/.node',
type: 'D',
....}
from adding:
if (getAPIFileType(name) && !anymatch(ignorePatterns, name)) {
nonIgnoredFilePaths.push(name);
var file = {
name: formattedName,
type: getAPIFileType(name),
source: contents[i] //the file contents
};
console.log({name});
console.log(file);
return file;
}
Only ignore which did work:
node_modules/**
node_modules/fsevents/build/Release/.deps/Release/.node.d
**/**
Specifications
- Node version (
node -v) : v8.9.4 - Version (
npm list | grep clasp): “@google/clasp@1.1.5” - OS (Mac/Linux/Windows): MAC
Maybe you guys should update or drop anymatch?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 23 (11 by maintainers)
Also, you can put all the files you do want to push in a folder (eg,
src/orGAS/) and then add a line in your.clasp.jsonfile, specifying which folder to push.That works pretty well for me, as an alternative to using .claspignore.
For the
node_modulescase I found success by adding the following three lines to.claspignore:That said, the
.claspignoresyntax should be made compatible with.gitignoreas much as possible.claspstill doesn’t ignorenode_modules(also got me very pissed at clasp, since it was getting stuck on “pushing files” without me knowing it’s trying to upload a (as usual) massive node_modules (simply containing clasp and typescript, since I like keeping things local), my workaround was to put my files in a src folder so it can be used with typescript.I deleted the node modules, did a
clasp push,npm install-ed them again, and now they seem to be properly ignored. Does that make sense? Doesclasp pushretain some kind of memory of what it tried/failed to push last time?So this issues has been hard to fix since
getProjectFilesis a 130 line beast. 👹https://github.com/google/clasp/blob/9a390c6/src/files.ts#L73
I’ll try to refactor the code to make it more maintainable and some more progress here.
PRs welcome. We should at least warn if we’re going to try to push 100+ files.
micromatch/glob/anymatch treat dotfiles differently because default bash glob behavior is not to have the dotglob option enabled: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
I think though that claspignore behavior should match gitignore behavior instead of bash otherwise we’ll run into more situations like this.
@grant, what are your thoughts on using a matching library that matches gitignore behavior (ie: https://www.npmjs.com/package/globby#globbygitignoreoptions) instead?
I’m seeing this too. It looks like an upstream bug with
anymatchhaving to do with dotfiles:It’s broken in the most recent release of anymatch.
I found a workaround, by adding these claspignore entries, but I imagine YMMV: