包详细信息

file-deps

matthewmueller55MIT0.0.11

parse and rewrite the dependencies of a file

dependencies, parser, rewriter

自述文件

file-deps

Find and replace all the dependencies in a JS or CSS file.

Example

// parse
var reqs = deps('require("./hi")', 'js') // ['./hi']

// rewrite
var str = deps('require("hi")', 'js', function(req) {
    return 'hello';
})
// require("hello")

API

deps(str, ext, [fn])

Parse the string str for dependencies. Parser depends on ext. If fn is present, you can rewrite the dependencies. fn's signature is fn(dep, ext).

TODO

  • Add html dependency parser

Test

npm install
make test

License

(The MIT License)

Copyright (c) 2014 Matthew Mueller <mattmuelle@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

更新日志

0.0.11 / 2015-11-30

  • don't change the asset paths but test for uniqueness

0.0.10 / 2015-11-30

  • Revert "if css doesn't have './', add it in"

0.0.9 / 2015-11-30

  • if css doesn't have './', add it in

0.0.8 / 2014-11-08

  • Fixes #7 - Treat ./<foo.bar> and <foo.bar> as duplicate paths
  • Update mocha
  • Remove duplicate filepaths when reading deps

0.0.7 / 2014-10-26

  • adding hook for configuring custom types
  • package.json: Add "repository" to make npm shut up
  • Makefile: install dependencies before running unit tests
  • Add .gitignore
  • lib/js: Refactor to use detective for finding requires

0.0.6 / 2014-08-03

  • fix css replacements

0.0.5 / 2014-06-29

  • Merge branch 'remove/import'
  • replace urls() sources, but replace @imports entirely
  • add test for object literals

0.0.4 / 2014-06-15

  • fix for multiple url(...) in a single statement

0.0.3 / 2014-06-15

  • return false or null to remove the statement entirely

0.0.2 / 2014-05-29

  • dont fail when file-deps cannot read the extension

0.0.1 / 2014-05-27

  • Initial commit