Skip to content

Instantly share code, notes, and snippets.

View lencioni's full-sized avatar

Joe Lencioni lencioni

  • Airbnb
  • Northfield, Minnesota, USA
  • X @lencioni
View GitHub Profile
@lencioni
lencioni / find-dead-js-modules.sh
Last active June 26, 2017 18:51 — forked from trotzig/find-dead-js-modules.sh
This script will find javascript modules that aren't currently used in your application.
#!/bin/bash
# Make the script fail on the first error encountered.
set -euo pipefail
# Create a temp folder that we can use to store files in.
if [ "$(uname -s)" = "Darwin" ]; then
tmp_dir=$(mktemp -d -t find-dead-modules.XXXXXXXX)
else
tmp_dir=$(mktemp -d --tmpdir find-dead-modules.XXXXXXXX)
# Converts global chained `var`s into single-line vars.
#
# Example:
#
# >> cat app/assets/javascripts/test.js
# var A = require('a'),
# B = require('b'),
# C = B.C;
#
# var D = function() {};