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]
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
  • What is the "curry" you use in your code? I use "curry" package from npm and your code works fine. – Yoshi Aug 18 '16 at 02:48
  • I use `lodash/fp/curry`, I removed the curry but I am still facing the issue when I yielded the result of invoking `mkdirp`, it says that the function does not return a promise. I could do this synchronously but I dont want to – vamsiampolu Aug 18 '16 at 10:57

0 Answers0