_origamiManifestPathForDirectory: Q.async(function*(dir) {
		const newPath = dir + '/origami.json';
		if (yield pfs.pathExists(newPath)) return newPath;

		const oldPath = dir + '/.origamiconfig'; // backward compat only
		if (yield pfs.pathExists(oldPath)) return oldPath;

		return null;
	}),
	_addModulesToBowerManifest: Q.async(function*(modules) {
		const log = this.log;
		const manifestPath = path.join(this.options.dir, 'bower.json');

		let bowerManifest;
		if (yield pfs.pathExists(manifestPath)) {
			bowerManifest = JSON.parse(yield pfs.readFile(manifestPath, 'utf8'));
			if ('object' !== typeof bowerManifest.dependencies) {
				bowerManifest.dependencies = {};
			}
			modules.forEach(function(m){
				delete bowerManifest.dependencies[m.endpoint.name]; // overwrite modules from existing manifest
			});
		} else {
			bowerManifest = {
				'name':'__MAIN__',
				'dependencies': {},
			};
		}

		// bower install with list of URLs can't resolve versions properly.
		// It's neccessary to create a temporary manifest file.
		modules.forEach(function(m){
			const name = m.endpoint.name;
			if (!name) throw new Error('Internal error, missing name for: ' + m.moduleName); // just a sanity check. ModuleSet should never allow it.

			// Can't use m.endpointString, because it could contain the name, and Bower doesn't like that
			let endpointString = EndpointParser.compose({source:m.endpoint.source, target:m.endpoint.target});

			// Target is required for non-URL modules, otherwise bower interprets them as branch/version name
			if (endpointString.indexOf('#') < 0) endpointString += '#*';

			if (bowerManifest.dependencies[name] && bowerManifest.dependencies[name] !== endpointString) {
				throw new HTTPError(400, 'Module '+name+' (' + m.moduleName + ') has been specified more than once:\n - ' +
					endpointString + '\n - ' + bowerManifest.dependencies[name]);
			}
			bowerManifest.dependencies[name] = endpointString;
		});

		log.info({modules: bowerManifest.dependencies, dest: this.options.dir}, 'Installing a new module set');

		return pfs.outputFile(manifestPath, JSON.stringify(bowerManifest));
	}),
						yield Q.all(['js','css','scss'].map(function(extension){
							const mainPath = paths[j] + '/main.' + extension;
							return pfs.pathExists(mainPath).then(function(exists){
								if (exists) files.push(mainPath);
							});
						}));