Mrm Core Versions Save

Utilities to make tasks for Mrm

v3.1.1

6 years ago
  • Fixed: Fix an issue that copyFIles is unable to overwrite calling script itself (#15)

v3.1.0

6 years ago

v3.0.3

6 years ago
  • Fixed: getExtsFromCommand should return undefined instead of an empty array

v3.0.2

6 years ago
  • Fixed: getExtsFromCommand should return undefined for empty command

v3.0.1

6 years ago
  • Fixed: packageJson: insert prescript before script, insert postscript after script

v3.0.0

6 years ago

Breaking changes

Node 4 is no longer supported, min Node version is 6.9.

New features

  • npm install can accept required package versions (#12, mrm#23):

    const { install } = require('mrm-core')
    install({ lodash: '4.17.3' }) // Install particular version
    install(['lodash'], { versions: { lodash: '4.17.3', other: '1.0.0' } }) // Install particular version
    

    Warning: Possibly breaking change: install will not read package.json anymore, it will take installed packages by reading node_modules/pkg/package.json.

  • packageJson.getScript accepts an optional subcommand param:

    const { packageJson } = require('mrm-core')
    const file = packageJson({ default: 'values' })
    file.getScript('test')  // Return script
    file.getScript('test', 'eslint')  // Return a subcommand of a script
    

    Note: subcommand is a command between && in an npm script. For example, prettier --write '**/*.js' && eslint . --fix has two subcommands: prettier… and eslint….

  • New method getExtsFromCommand to get file extensions list from a command like eslint . --fix --ext .js,.jsx:

    const { getExtsFromCommand } = require('mrm-core')
    getExtsFromCommand(`eslint . --fix --ext .js,.jsx`, 'ext')
    // => ['js', 'jsx']
    getExtsFromCommand(`prettier --write '**/*.js'`)
    // => ['js']
    
  • install/uninstall will run Yarn if project is already using Yarn.

v2.6.0

6 years ago

New features

Yarn support in install and uninstall methods:

const { install, uninstall } = require('mrm-core')

uninstall(['eslint'], { yarn: true })
install(['standard'], { yarn: true })

(Thanks @TrySound!)

Bug fixes

Fix: Ensure that a folder exists before saving a file

v2.5.0

6 years ago

Expose EditorConfig utilities:

const { inferStyle, getStyleForFile, getIndent, format } = require('mrm-core')
inferStyle('for (;;) {\n  alert(1);\n}\n')
// => { insert_final_newline: true, indent_style: 'space', indent_size: 2 }
getStyleForFile('test.js')
// => { insert_final_newline: false, indent_style: 'tab', indent_size: 'tab' }
getIndent({ indent_style: 'space', indent_size: 2 })
// => '  '
format('alert(1)\n', { insert_final_newline: false })
// => 'alert(1)'
// Only insert_final_newline is supported

v2.4.0

6 years ago

New features

Initial EditorConfig support

  1. It will try to infer code style from the original file. For new files it’ll read EditorConfig setting for that file. Which means it won’t reformat your files even if they have wrong formatting — code formatting is not the goal of Mrm but making as little changes as possible is.
  2. insert_final_newline is applied to all files on save.
  3. indent_size and indent_style options are applied to JSON files only.

Support comments in JSON

To add a comment:

const { json } = require('mrm-core')
json('test.json')
  .set({
    '// key': [['// Comment for key']],
    key: 'Pizza'
  })
  .save()

v2.3.1

6 years ago
  • Fix: Do not remove empty lines on saving in lines() method