gulp-shopify-theme icon indicating copy to clipboard operation
gulp-shopify-theme copied to clipboard

Is it possible to delete a single file from shopify?

Open shborrowman opened this issue 6 years ago • 5 comments

Maybe I am just missing something but I can not seem to figure out how to delete a single file. After doing some messing around in the code a bit I noticed that the return through.obj(function(file, encoding, callback) doesn't fire on a delete. I'm not sure if it's because of how I am calling the module or if it just doesn't work that way. I'm currently calling the module by adding a watch to all my folders and files I want pushed to shopify gulp.watch('dist/{assets,layout,config,sections,snippets,templates,locales}/**/*.*', (event) => { shopifyUpload(event.path); });

and passing the changed file to a function that is calling the gulp-shopify-theme stream function shopifyUpload(path) { return gulp.src(path) .pipe(shopifytheme.stream()); };

Any help with this would be much appreciated.

shborrowman avatar Jul 20 '18 14:07 shborrowman

Does it work if you do console.log(event) instead of shopifyUpload(event.path);? Then we'll know if it’s a watch thing or something else downstream.

tmslnz avatar Jul 20 '18 18:07 tmslnz

Yes, the delete is registered in my gulp file along with the path of the item being deleted. And the stream function in the module does run on a delete. It's the through.obj that doesn't seem to run on a delete so the else if (file.isNull()) is never checked and the file.action = 'deleted'; is never set.

shborrowman avatar Jul 20 '18 18:07 shborrowman

Just messing around with the module, I have been able to get it to work if I create my own 'delete' function and task. I added delete (file) { this._runDeleteTask(file); } and the task just has what you had in the 'deleted' case for your _runAssetTask. So, it looks like this. _runDeleteTask (file) { var params = {}; var verb; params.asset = {key: file}; verb = 'delete'; return this.api.asset[verb](this._themeId, params); }

and I call it with an event.type if statement in my watch gulp.watch('dist/{assets,layout,config,sections,snippets,templates,locales}/**/*.*', (event) => { if (event.type == 'deleted') { shopifytheme.delete(event.path); } else { shopifyUpload(event.path); } });

This is, obviously, a temporary fix because it doesn't add the deleted files to the _queue and I don't want to change the code in the module. It does, however, tell me that the way I have it set up is working but there is something about the through.obj function that isn't working with a deleted file.

shborrowman avatar Jul 25 '18 14:07 shborrowman

Thanks for investigating. I’ve not had time yet to do it myself, but I should be able to peek into the code soon.

tmslnz avatar Jul 25 '18 14:07 tmslnz

I was wondering how this issue is going as I too would like there to be a single file delete option. Thanks

YewTreeWeb avatar Aug 23 '18 16:08 YewTreeWeb