pattern-utils.js 376 B

1234567891011121314
  1. 'use strict'
  2. const path = require('path')
  3. const PatternUtils = {
  4. getBaseDir (pattern) {
  5. return pattern
  6. .replace(/[/\\][^/\\]*\*.*$/, '') // remove parts with *
  7. .replace(/[/\\][^/\\]*[!+]\(.*$/, '') // remove parts with !(...) and +(...)
  8. .replace(/[/\\][^/\\]*\)\?.*$/, '') || path.sep // remove parts with (...)?
  9. }
  10. }
  11. module.exports = PatternUtils