Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
A very useful build step; read any number of files, process them as JavaScript templates, and save output to another destination.
A very useful build step; read any number of files, process them as JavaScript templates, and save output to another destination.
Process an input directory to an output directory recursively:
samson -i path/to/directory -o path/to/other/directory -R
Samson's functionality can be summarized in 3 steps:
Include samson in your own module:
var samson = require('samson');
samson.run(['source/dir/**/*'], {
copyUnknown : true,
outputDir : 'build/dir',
recursive : true
});
Sounds pretty simple right?
The unique part of Samson is in step #2. doT.js is both the fastest, and most open-ended JavaScript template engine I've found to date, and is the engine I believe to be best suited for the task I'm trying to achieve with Samson. If you are familiar with doT, skip to the next section, otherwise now would be a good time to visit http://olado.github.com/doT/
With npm this module prefers global installation:
npm i samson -g
One thing doT allows, is defining custom delimiters before compiling a string into a template, and with that I have defined different settings for the most common comment block delimiters.
A quick look at these settings:
<!--{
}-->
/*{
}*/
#{
}#
A more detailed view of these settings can be found here http://drkibitz.github.com/node-samson/docs/0.3.1/Template.settingsByType.html
Take a look at the following example in my-file.js
, that is not processed with Samson:
/* start */
/*{?argv.target !== 'release'}*/
var DEBUG = true;
/*{?}*/
/* end */
Process with Samson as samson my-file.js
outputs:
/* start */
var DEBUG = true;
/* end */
Process with Samson as samson my-file.js --target release
outputs:
/* start */
/* end */
Notice the argv
member accessible in the doT template. This object contains all of the script arguments parsed by the module optimist, and passed directly into the doT template.
Just as within doT, the def
object is special. Once a member property is set, it may not be changed. There is one def
object defined for each file, and one file's template may not access another file's def
.
Additionally but not limited to, enumerables set within def
are passed directly to the template's runtime function as arguments. What this means is /*{#def.FILE}*/
, may also be accessed as /*{=FILE}*/
For a more detailed view of the defailt members of def
, please visit http://drkibitz.github.com/node-samson/docs/0.3.1/ResourceProcessor.def.html
Be sure to to look at:
samson
samson -h
samson --help
Process a single file and output to console:
samson path/to/file
Process a single file and output to file system:
samson path/to/file -o path/to/directory
Process multiple files and output to file system:
samson path/to/file1 path/to/file2 path/to/file3 -o path/to/directory
Process single directory recursively and output to file system:
samson path/to/directory -o path/to/directory -R
Process files and directories recursively and output to file system:
samson path/to/dir1 path/to/file path/to/dir2 -o path/to/directory -R
Process matched files recursively and output to file system:
samson -i path/to/* -o path/to/other/directory -R
FAQs
A very useful build step; read any number of files, process them as JavaScript templates, and save output to another destination.
We found that samson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.