taptapship / wiredep

Wire Bower dependencies to your source code.
MIT License
1.15k stars 142 forks source link

NPM package doesn't have pug support #271

Open ahmadalfy opened 7 years ago

ahmadalfy commented 7 years ago

Pug support was added last year still the packages are not in sync. This is the content of the default-file-types.js

var regex = {
  block: {
    '//': /(([ \t]*)\/\/\s*bower:*(\S*))(\n|\r|.)*?(\/\/\s*endbower)/gi
  }
};

module.exports = {
  html: {
    block: /(([ \t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
    detect: {
      js: /<script.*src=['"]([^'"]+)/gi,
      css: /<link.*href=['"]([^'"]+)/gi
    },
    replace: {
      js: '<script src="{{filePath}}"></script>',
      css: '<link rel="stylesheet" href="{{filePath}}" />'
    }
  },

  js: {
    block: regex.block['//'],
    detect: {
      js: /['"]([^'"]+\.js)['"],?/gi,
      css: /['"]([^'"]+\.js)['"],?/gi
    },
    replace: {
      js: '"{{filePath}}",',
      css: '"{{filePath}}",'
    }
  },

  jade: {
    block: /(([ \t]*)\/\/-?\s*bower:*(\S*))(\n|\r|.)*?(\/\/-?\s*endbower)/gi,
    detect: {
      js: /script\(.*src=['"]([^'"]+)/gi,
      css: /link\(.*href=['"]([^'"]+)/gi
    },
    replace: {
      js: 'script(src=\'{{filePath}}\')',
      css: 'link(rel=\'stylesheet\', href=\'{{filePath}}\')'
    }
  },

  slim: {
    block: /(([ \t]*)\/!?\s*bower:(\S*))(\n|\r|.)*?(\/!?\s*endbower)/gi,
    detect: {
      js: /script.*src=['"]([^'"]+)/gi,
      css: /link.*href=['"]([^'"]+)/gi
    },
    replace: {
      js: 'script src=\'{{filePath}}\'',
      css: 'link rel=\'stylesheet\' href=\'{{filePath}}\''
    }
  },

  less: {
    block: regex.block['//'],
    detect: {
      css: /@import\s['"](.+css)['"]/gi,
      less: /@import\s['"](.+less)['"]/gi
    },
    replace: {
      css: '@import "{{filePath}}";',
      less: '@import "{{filePath}}";'
    }
  },

  sass: {
    block: regex.block['//'],
    detect: {
      css: /@import\s(.+css)/gi,
      sass: /@import\s(.+sass)/gi,
      scss: /@import\s(.+scss)/gi
    },
    replace: {
      css: '@import {{filePath}}',
      sass: '@import {{filePath}}',
      scss: '@import {{filePath}}'
    }
  },

  scss: {
    block: regex.block['//'],
    detect: {
      css: /@import\s['"](.+css)['"]/gi,
      sass: /@import\s['"](.+sass)['"]/gi,
      scss: /@import\s['"](.+scss)['"]/gi
    },
    replace: {
      css: '@import "{{filePath}}";',
      sass: '@import "{{filePath}}";',
      scss: '@import "{{filePath}}";'
    }
  },

  styl: {
    block: regex.block['//'],
    detect: {
      css: /@import\s['"](.+css)['"]/gi,
      styl: /@import\s['"](.+styl)['"]/gi
    },
    replace: {
      css: '@import "{{filePath}}"',
      styl: '@import "{{filePath}}"'
    }
  },

  yaml: {
    block: /(([ \t]*)#\s*bower:*(\S*))(\n|\r|.)*?(#\s*endbower)/gi,
    detect: {
      js: /-\s(.+js)/gi,
      css: /-\s(.+css)/gi
    },
    replace: {
      js: '- {{filePath}}',
      css: '- {{filePath}}'
    }
  },

  haml: {
    block: /(([ \t]*)-#\s*bower:*(\S*))(\n|\r|.)*?(-#\s*endbower)/gi,
    detect: {
      js: /\%script\{.*src:['"]([^'"]+)/gi,
      css: /\%link\{.*href:['"]([^'"]+)/gi
    },
    replace: {
      js: '%script{src:\'{{filePath}}\'}',
      css: '%link{rel:\'stylesheet\', href:\'{{filePath}}\'}'
    }
  }
};

module.exports['default'] = module.exports.html;
module.exports.htm = module.exports.html;
module.exports.yml = module.exports.yaml;

I know the workarounds to get pug working, just please fix the npm package.

Thank you