Port clean script to NodeJS