Marmot (mrm) core utils
Utilities to make tasks for mrm.
Taks example
This task adds ESLint to your project:
'use strict';
const { json, lines, install } = require('mrm-core');
const defaultTest = 'echo "Error: no test specified" && exit 1';
const packages = [
'eslint',
'eslint-config-tamia',
];
module.exports = function() {
const eslintrc = json('.eslintrc');
if (!eslintrc.get('extends').startsWith('tamia')) {
eslintrc
.set('extends', 'tamia')
.save()
;
}
const eslintignore = lines('.eslintignore');
eslintignore
.append('node_modules')
.save()
;
const packageJson = json('package.json')
.merge({
scripts: {
lint: 'eslint . --ext .js --fix',
},
})
;
const test = packageJson.get('scripts.test');
if (!test || test === defaultTest) {
packageJson.set('scripts.test', 'npm run lint');
}
else if (!test.includes('lint')) {
packageJson.set('scripts.test', `npm run lint && ${test}`);
}
packageJson.save();
if (!packageJson.get('dependencies.eslint-config-tamia')) {
install(packages);
}
};
module.exports.description = 'Adds ESLint with a custom preset';
Read more in mrmâs docs, and this talks is already included by default.
You can find more examples here.
Installation
npm install --save-dev mrm-core
API
const { ini, json, lines, markdown, template, yaml, install, MrmError } = require('mrm-core');
- Modules to work with files of different formats:
ini
, json
, lines
, markdown
, template
, yaml
. - Install Yarn/npm packages:
install
. - Custom error class:
MrmError
.
Changelog
The changelog can be found on the Releases page.
Contributing
Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.
Authors and license
mrm and contributors.
MIT License, see the included License.md file.