0

I have a generator function that creates a directory and performs operations on it once done:

import co from 'co'    
import map from 'lodash/fp/map'
import path from 'path'
import {mkdirp} from 'fs-promise'
import co from 'co'


 export const createDirectoryForMake = (parentDir,makeName) => {
  const dirPath = path.join(parentDir,makeName)
  return mkdirp(dirPath)
}


function getGenerateMakeOutput(parentDir,byMake,makeName){
   function * generateMakeOutput() {
    try {
      console.log('before create directory for make')
      const dirStatus = yield createDirectoryForMake(parentDir,makeName)
      } catch(e) {
        console.error(e)
      }
  }

  co(generateMakeOutput)

}

This is the output that I get when I execute the code:

TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "undefined"
    at next (/home/vamsi/Do/redbubble-demo/node_modules/co/index.js:101:25)
    at onFulfilled (/home/vamsi/Do/redbubble-demo/node_modules/co/index.js:69:7)
    at run (/home/vamsi/Do/redbubble-demo/node_modules/core-js/modules/es6.promise.js:89:22)
    at /home/vamsi/Do/redbubble-demo/node_modules/core-js/modules/es6.promise.js:102:28
    at flush (/home/vamsi/Do/redbubble-demo/node_modules/core-js/modules/_microtask.js:18:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

UPDATE:

I found the issue, it is not with the code in the sample there but with a line below it where I wrote this gem:

yield Promise.all[promiseA,promiseB]
4

0 に答える 0