lib/render.js
function complete() {
  quit();

  const deleteQueue = [];
  fs.readdir(paths.output, (err, files) => {
    if (files) {
      // lookup array for quick search inside existing component names
      const componentsLookup = components.map(item => {
        return slugify(item.meta.name);
      });

      // loop over files
      for (let i = 0, l = files.length; i < l; ++i) {
        const file = files[i];
        const ext = path.extname(file);

        // ignore dot files
        if (file.indexOf(".") === 0) {
          continue;
        }

        // if json+html file isn't inside lookup, mark for deletion
        if (componentsLookup.indexOf(path.basename(file, ext)) === -1) {
          deleteQueue.push(file);
        }
      }
    }

    // remove file by passing shorter queue
    function removeFile(q) {
      if (!q.length) {
        process.send(true);
        return;
      }

      const file = q.shift();
      rimraf(path.resolve(paths.output, file), { read: false }, () => {
        removeFile(q);
      });
    }

    removeFile(deleteQueue);
  });
}
function complete() {
  quit();

  const deleteQueue = [];
  fs.readdir(paths.output, (err, files) => {
    if (files) {
      // lookup array for quick search inside existing component names
      const componentsLookup = components.map(item => {
        return slugify(item.meta.name);
      });

      // loop over files
      for (let i = 0, l = files.length; i < l; ++i) {
        const file = files[i];
        const ext = path.extname(file);

        // ignore dot files
        if (file.indexOf(".") === 0) {
          continue;
        }

        // if json+html file isn't inside lookup, mark for deletion
        if (componentsLookup.indexOf(path.basename(file, ext)) === -1) {
          deleteQueue.push(file);
        }
      }
    }

    // remove file by passing shorter queue
    function removeFile(q) {
      if (!q.length) {
        process.send(true);
        return;
      }

      const file = q.shift();
      rimraf(path.resolve(paths.output, file), { read: false }, () => {
        removeFile(q);
      });
    }

    removeFile(deleteQueue);
  });
}
function complete ( ) { quit ( ) ; const deleteQueue = [ ] ; fs . readdir ( paths . output , ( err , files ) => { if ( files ) { // lookup array for quick search inside existing component names const componentsLookup = components . map ( item => { return slugify ( item . meta . name ) ; } ) ; // loop over files for ( let i = 0 , l = files . length ; i < l ; ++ i ) { const file = files [ i ] ; const ext = path . extname ( file ) ; // ignore dot files if ( file . indexOf ( "." ) === 0 ) { continue ; } // if json+html file isn't inside lookup, mark for deletion if ( componentsLookup . indexOf ( path . basename ( file , ext ) ) === - 1 ) { deleteQueue . push ( file ) ; } } } // remove file by passing shorter queue function removeFile ( q ) { if ( ! q . length ) { process . send ( true ) ; return ; } const file = q . shift ( ) ; rimraf ( path . resolve ( paths . output , file ) , { read : false } , ( ) => { removeFile ( q ) ; } ) ; } removeFile ( deleteQueue ) ; } ) ; }
Clean up unused files and shut down
Clean up unused files and shut down