get-context-directory.js 523 B

1234567891011121314151617
  1. 'use strict';
  2. var path = require('path');
  3. /**
  4. * Infer the compilation context directory from options.
  5. * Relative paths are resolved against process.cwd().
  6. * @this {{options: object}} A loader or compilation
  7. * @returns {string} process.cwd() where not defined else the output path string
  8. */
  9. function getContextDirectory() {
  10. /* jshint validthis:true */
  11. var context = this.options ? this.options.context : null;
  12. return !!context && path.resolve(context) || process.cwd();
  13. }
  14. module.exports = getContextDirectory;