You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
566 B

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