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

Is it possible to delete a single file from shopify? #7

Open
shborrowman opened this issue Jul 20, 2018 · 5 comments
Open

Is it possible to delete a single file from shopify? #7

shborrowman opened this issue Jul 20, 2018 · 5 comments

Comments

@shborrowman
Copy link

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.

@tmslnz
Copy link
Owner

tmslnz commented Jul 20, 2018 via email

@shborrowman
Copy link
Author

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
Copy link
Author

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.

@tmslnz
Copy link
Owner

tmslnz commented Jul 25, 2018 via email

@YewTreeWeb
Copy link

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

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

3 participants