Search code examples
node.jsrm

how to remove everything with rimraf except few exceptions


i’m trying to remove all .dot files, except .git and all *.js except one exception.js, but i’m failing

install

git clone git@github.com:iamstarkov/rimraf-test.git
cd rimraf-test

test

npm test # it fails

can anybody help me?


Solution

  • var globby = require('globby');
    var rimraf = require('rimraf');
    
    globby(['*', '!authors.js', '!.git', '!dump'])
      .then(function then(paths) {
        paths.map(function map(item) {
          rimraf.sync(item);
        });
      });