Node Roundup: No More Force Publish, Counterpart, mock-fs

2014-02-26 00:00:00 +0000 by Alex R. Young

No More Force Publish

Isaac Z. Schlueter wrote on npm's blog that publish -f will no longer work:

If you publish foo@1.2.3, you can still un-publish foo@1.2.3. But then, you will not be able to publish something else to that same package identifier and version. Ever.

The common wisdom is changing the code that a version number describes is dangerous, so it's better to publish a new version. If you're a module author, you may feel that this is frustrating -- what if you just released something with a dangerous security flaw? In cases like this it may be best to remove the version and publish a new, fixed version.


Counterpart (GitHub: martinandert / counterpart, License: MIT, npm: counterpart) by Martin Andert is an internationalisation module based on Ruby's I18n gem:

translate('damals.about_x_hours_ago.one')          // => 'about one hour ago'
translate(['damals', 'about_x_hours_ago', 'one'])  // => 'about one hour ago'
translate(['damals', 'about_x_hours_ago.one'])     // => 'about one hour ago'

You can write translation documents using JSON. Features include interpolation, pluralisation, and default fallbacks.


mock-fs (GitHub: tschaub / mock-fs, License: MIT, npm: mock-fs) by Tim Schaub is an API-compatible version of Node's fs module that essentially allows you to temporarily use an in-memory filesystem.

It provides a mock function that accepts a specification of the files you want to mock:

  'path/to/fake/dir': {
    'some-file.txt': 'file content here',
    'empty-dir': {/** empty directory */}
  'path/to/some.png': new Buffer([8, 6, 7, 5, 3, 0, 9]),
  'some/other/path': {/** another empty directory */}

You might find this useful if you want to write tests that avoid touching real files.