import { logger } from '../src' import { option } from './' import * as path from 'path' import { CONFIG_DEFAULT, IOSRConfig } from '@plastichub/osr-cli-commons' import { Promise as BPromise } from 'bluebird' import { isArray } from '@plastichub/core/primitives' import { resolve } from '@plastichub/osr-cli-commons/fs' import { addFromFolder as update } from '@plastichub/osr-cscart/lib/cscart/product' const updateProducts = async (items: string[], config, options) => { return BPromise.resolve(items).map((item) => { return update(item, config, options.vendor) }, { concurrency: 1 }); } export const register = (grunt) => { grunt.registerMultiTask('cscart', 'Deploy product to CSCart', async function () { const done = this.async(); const task_options = this.data.options || {} const config = CONFIG_DEFAULT() as IOSRConfig const options = { ...this.data.options, debug: option('debug', task_options, grunt), verbose: option('verbose', task_options, grunt), vendor: option('vendor', task_options, grunt) } const src = this.data.src.map(f => (resolve(f))) options.debug && logger.info('Compile - task data ', process.cwd(), this.data, src) let ret = await updateProducts(src, config.cscart, options.vendor) debugger; }); };