1.0.2 • Published 8 years ago
moduletag v1.0.2
moduletag
Creates a string tag
for a given file/module which can be used for output generated by the module, e.g. in logs.
The format for a moduletag
is:
<moduletag> ::= <package path> : <filetag>
<filetag> ::= <relative path to module> / <filename without ext>
<package path>
is forward-slash separated string of the file's package, and any other packages up the directory tree, e.g. for when the package is installed as a dependency of another package.<filetag>
is the relative path and filename (without extension) of the module file from the enclosing package's directory.
Uses pkginfo-async
to retrieve the module's package information.
Installation
Install with npm
npm install moduletag
Example
var moduletag = require("moduletag")
moduletag( module, function ( err, pkg ) {
// err is an error object or null.
// pkg is the contents of the package.json or null
})
Here's the tag for the main file in moduletag
moduletag:lib/moduletag
moduletag(file, cb)
file
{String | Object}
{String}
filename{Object}
nodejs module object of the file
cb
{Function(err, pkg)}
err
{Error | null}
tag
{Object | null}
the generated tag
- Returns a promise which resolves with the generated tag
Creates a tag for the given module/file.