| 32 | }; |
| 33 | |
| 34 | function runEndpointGen(name, opt={}) { |
| 35 | let prompts = opt.prompts || {}; |
| 36 | let options = opt.options || {}; |
| 37 | let config = opt.config; |
| 38 | |
| 39 | return new Promise((resolve, reject) => { |
| 40 | let dir; |
| 41 | let gen = helpers |
| 42 | .run(require.resolve('../generators/endpoint')) |
| 43 | .inTmpDir(function(_dir) { |
| 44 | // this will create a new temporary directory for each new generator run |
| 45 | var done = this.async(); |
| 46 | if(DEBUG) console.log(`TEMP DIR: ${_dir}`); |
| 47 | dir = _dir; |
| 48 | |
| 49 | // symlink our dependency directories |
| 50 | return fs.symlinkAsync(__dirname + '/fixtures/node_modules', dir + '/node_modules') |
| 51 | .then(done); |
| 52 | }) |
| 53 | .withOptions(options) |
| 54 | .withArguments([name]) |
| 55 | .withPrompts(prompts); |
| 56 | |
| 57 | if(config) { |
| 58 | gen |
| 59 | .withLocalConfig(config); |
| 60 | } |
| 61 | |
| 62 | gen |
| 63 | .on('error', reject) |
| 64 | .on('end', () => resolve(dir)); |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | const ESLINT_CMD = path.join(TEST_DIR, '/fixtures/node_modules/.bin/eslint'); |
| 69 | |