same-author

Test to see if a file was written by you. Useful for babel/webpack conditional loading.

Usage no npm install needed!

<script type="module">
  import sameAuthor from 'https://cdn.skypack.dev/same-author';
</script>

README

same-author

Test to see if a file was written by you. Useful for babel/webpack conditional loading.

Install

npm install same-author

Usage

Babel
var sameAuthor = require('same-author');
require('babel-core/register')({
  only: sameAuthor
});
Webpack
{
  ...
  module: {
    loaders: [{
      test: function (filename) {
        // Uses the babel loader for both this app's code, but also any npm
        // dependencies that you wrote.
        return sameAuthor(filename) && new RegExp(/\.js$/).test(filename);
      },
      loader: 'babel'
    }]
  }
  ...
}
Standalone
import writtenBySameAuthor from 'same-author';
var isSameAuthor = writtenBySameAuthor('./node_modules/same-author', process.cwd());
// the second arg is optional. defaults to cwd.
// in this example, process.cwd() is written by you, so this tests if your dependency "same-author" was also written by you.
// isSameAuthor will be true for me, but not for you.