mikenorthorp / gulp-shopify-upload

gulp plugin to watch and upload files to Shopify for use in theme editing
Other
40 stars 21 forks source link

Callback after every file is uploaded #8

Closed clementoriol closed 9 years ago

clementoriol commented 9 years ago

Hi ! Thanks for the plugin, it's currently working very well for me. However, I'm having issue reloading the page once every file is uploaded.

I'm trying to chain tasks, and gulp seems to have some issue with knowing when the gulpShopify uploads are done. It seems to trigger the task end too early.

Is there any kind of callback implemented in your plugin ? Or do you have any idea how it could be accomplished ?

Thank you

mikenorthorp commented 9 years ago

We use browsersync with a slight delay since we currently dont have any way to know when its finished uploading. This refreshes the page when assets are uploaded.

On Tue, Jun 30, 2015 at 7:22 AM, Clément Oriol notifications@github.com wrote:

Hi ! Thanks for the plugin, it's currently working very well for me. However, I'm having issue reloading the page once every file is uploaded.

I'm trying to chain tasks, and gulp seems to have some issue with knowing when the gulpShopify uploads are done. It seems to trigger the task end too early.

Is there any kind of callback implemented in your plugin ? Or do you have any idea how it could be accomplished ?

Thank you

— Reply to this email directly or view it on GitHub https://github.com/mikenorthorp/gulp-shopify-upload/issues/8.

pushred commented 9 years ago

Why not defer the through2 callback until shopify.upload returns it's own? shopify-api doesn't callback for the asset PUT method until a response is received. Seems to work for me like this:

browserSync.init({
  proxy: config.store
});

watch('.build')
  .pipe(shopify(config.api_key, config.password, config.store, config.theme_id, { basePath: '.build' }))
  .pipe(browserSync.stream());

See diff: https://github.com/mikenorthorp/gulp-shopify-upload/compare/master...pushred:upload-callback