copywriter v1.0.1
Copywriter
Installation
Locally
$ cd [repository root] && npm install --save-dev git@github.com:tonysickpony/copywriter.gitGlobally
$ npm install --global git@github.com:tonysickpony/copywriter.gitCommand line API
Locally
$ cd [repository root] && ./node_modules/.bin/copywriter -f /path/to/your/config/file.jsonGlobally
$ copywriter -f /path/to/your/config/file.jsonConfiguration file
see example config
{
"vars": {
"key": "value",
"key2": "value2"
},
"mappings": {
"inputFile1": "outputFile1",
"inputFile2": "outputFile2",
"inputDir": "outputDir"
},
"options": {
"templateExtensions": [
"tmp",
"otherTemplateFileFormat"
]
}
}Precedence
Latter entries will overide former entries. Files will always overide directories.
For example the configuration below:
{
"vars": {
"key": "value"
},
"mappings": {
"inputDir": "outputDir",
"inputDir/subDir": "outputDir2",
"inputDir/a.tmp": "file.ext"
},
"options": {
"templateExtensions": [
"tmp"
]
}
}with a file system structured like this:
└── inputDir
├── a.tmp
├── b.tmp
└── subDir
└── c.tmpwill generate file system structured like this:
├── file.ext
├── outputDir
│ └── b
└── outputDir2
└── cInterpolate variables
The templating uses lodash's _.template() function. Template delimiter we choose is handle bar/mustache style {{ variable }} and this is hardcoded for the moment.
So the template file may look like:
my keys:
- {{ key }}
- {{ key2 }}System Environment Variables
The system envs can be picked up using $ENV.envname style value. For instance to get the home directory you should write the variable like "myHOmeDir": "$ENV.home".
Uninstallation
Locally
$ cd [repository root] && npm rm --save-dev copywriterGlobally
$ npm rm --global copywriterDevelopment
Prerequisite
Download repository
$ git clone git://git@bitbucket.org:gorapid/rapid-template.git && cd rapid-templateInstall dependencies
$ npm installOr if you have yarn installed
$ yarn installRun tests. We choose ava as our test suite
$ npm testTest coverage. We choose nyc as our test coverage tool
$ npm run coverageCode style linting. We choose js standard as our code standard and linting tool
$ npm run lint