index.js
function processContentWithPostCSS(options, href) {
	/**
	 * @param  {String} content [css to process]
	 * @return {Object}         [object with css tokens and css itself]
	 */
	return function (content) {
		if (options.generateScopedName) {
			options.generateScopedName = typeof options.generateScopedName === 'function' ?
				/* istanbul ignore next */
				options.generateScopedName :
				genericNames(options.generateScopedName, {context: options.root});
		} else {
			options.generateScopedName = function (local, filename) {
				return Scope.generateScopedName(local, path.relative(options.root, filename));
			};
		}

		// Setup css-modules plugins 💼
		var runner = postcss([
			Values,
			LocalByDefault,
			ExtractImports,
			new Scope({generateScopedName: options.generateScopedName}),
			new Parser({fetch: fetch})
		].concat(options.plugins));

		function fetch(_to, _from) {
			// Seems ok 👏
			var filePath = normalizePath(_to, options.root, _from);

			return new Promise(function (resolve, reject) {
				return fs.readFile(filePath, 'utf8', function (err, content) {
					/* istanbul ignore next: just error handler */
					if (err) {
						return reject(err);
					}

					return runner.process(content, {from: filePath})
						.then(function (result) {
							return resolve(result.root.tokens);
						}).catch(reject);
				});
			});
		}

		return runner.process(content, {from: normalizePath(href, options.root, options.from)});
	};
}
function processContentWithPostCSS(options, href) {
	/**
	 * @param  {String} content [css to process]
	 * @return {Object}         [object with css tokens and css itself]
	 */
	return function (content) {
		if (options.generateScopedName) {
			options.generateScopedName = typeof options.generateScopedName === 'function' ?
				/* istanbul ignore next */
				options.generateScopedName :
				genericNames(options.generateScopedName, {context: options.root});
		} else {
			options.generateScopedName = function (local, filename) {
				return Scope.generateScopedName(local, path.relative(options.root, filename));
			};
		}

		// Setup css-modules plugins 💼
		var runner = postcss([
			Values,
			LocalByDefault,
			ExtractImports,
			new Scope({generateScopedName: options.generateScopedName}),
			new Parser({fetch: fetch})
		].concat(options.plugins));

		function fetch(_to, _from) {
			// Seems ok 👏
			var filePath = normalizePath(_to, options.root, _from);

			return new Promise(function (resolve, reject) {
				return fs.readFile(filePath, 'utf8', function (err, content) {
					/* istanbul ignore next: just error handler */
					if (err) {
						return reject(err);
					}

					return runner.process(content, {from: filePath})
						.then(function (result) {
							return resolve(result.root.tokens);
						}).catch(reject);
				});
			});
		}

		return runner.process(content, {from: normalizePath(href, options.root, options.from)});
	};
}
function processContentWithPostCSS ( options , href ) { /**
	 * @param  {String} content [css to process]
	 * @return {Object}         [object with css tokens and css itself]
	 */ return function ( content ) { if ( options . generateScopedName ) { options . generateScopedName = typeof options . generateScopedName === 'function' ? /* istanbul ignore next */ options . generateScopedName : genericNames ( options . generateScopedName , { context : options . root } ) ; } else { options . generateScopedName = function ( local , filename ) { return Scope . generateScopedName ( local , path . relative ( options . root , filename ) ) ; } ; } // Setup css-modules plugins 💼 var runner = postcss ( [ Values , LocalByDefault , ExtractImports , new Scope ( { generateScopedName : options . generateScopedName } ) , new Parser ( { fetch : fetch } ) ] . concat ( options . plugins ) ) ; function fetch ( _to , _from ) { // Seems ok 👏 var filePath = normalizePath ( _to , options . root , _from ) ; return new Promise ( function ( resolve , reject ) { return fs . readFile ( filePath , 'utf8' , function ( err , content ) { /* istanbul ignore next: just error handler */ if ( err ) { return reject ( err ) ; } return runner . process ( content , { from : filePath } ) . then ( function ( result ) { return resolve ( result . root . tokens ) ; } ) . catch ( reject ) ; } ) ; } ) ; } return runner . process ( content , { from : normalizePath ( href , options . root , options . from ) } ) ; } ; }
processes css with css-modules plugins
@param  {Object} options [plugin's options]
@return {Function}
processes css with css - modules plugins