Tool Sharpening

by Drew Barontini

Workflow automation is all about continual refinement. Nothing is perfect, and you will continually evaluate and improve your systems of organization. It’s an endless battle, and things can always be better.

Let’s talk about ways to identify areas for improvement, find out the best way to handle the issue, and set up a solution to improve efficiency.

Identify

The first step in the process is to identify the problem. Define the part of your workflow that requires an excess amount of manual work. Ask yourself, “What do I do repeatedly that takes a lot of time?”

Keeping a list

To keep track of these areas for improvement, I have a ‘Tool Sharpening’ Evernote document that I continually update. I might not be able to immediately fix an issue, but I will always write down that there is one. The important thing is to be sensitive to the manual tasks that take a lot of time.

Research

So let’s say that we’re now ready to take the steps to fix our issue. Before we jump into the actual automation phase, it’s important to spend time researching. Search Google and determine what solutions, if any, already exist. There might be an application, tool, or service that can help. If not, we can build our own custom solution.

Make sure to continually allot time for finding solutions to workflow problems. Don’t get complacent. Frequent Google searches will yield answers you didn’t even know existed.

Automate

Once we know what we want to automate and how we want to automate it, it’s time to actually fix the problem. The solution can be as simple as using a tool or application to accomplish the task. It can also be as complicated as writing a custom script to perform the task.

Example

On the front-end team at Code School, we use Sass and, particularly, indented Sass. We have specific conventions and guidelines for comments, spacing, and property order.

Identify

We were spending too much time in code reviews talking about those guidelines. Rather than discussing larger architectural issues, we were talking about nitty-gritty details better suited for the computer.

Research

Once we identified the problem, we started looking into existing solutions. Was there a Sass linter that we could use. Lo and behold, there was: the sass-lint linter fit the bill quite nicely.

But we wanted a simple solution to kickstart the linting in any project we worked on. So, with that, we built a bin script wrapper around the sass-lint CLI. The bin script would:

  • Run sass-lint on the files we passed in, if it was already set up
  • Set it up and then run it on the files we passed in, if it wasn’t already set up
  • Additionally, pull the .sass-lint.yml configuration file from drewbarontini/noise

And with this research in place, we set to the automation part of the process.

Automate

#!/usr/bin/env ruby
# *************************************
#
#   Sass Linter
#   -> Wrapper around 'sass-lint' CLI
#
# -------------------------------------
#   Usage
# -------------------------------------
#
#  `sass-linter stylesheets/*.sass`
#  `sass-linter stylesheets/*.sass stylesheets/**/*.sass`
#
# *************************************

# -------------------------------------
#   Variables
# -------------------------------------

@cli_directory    = "#{ ENV['HOME'] }/.npm/sass-lint"
@config_file      = '.sass-lint.yml'
@config_file_path = "https://raw.githubusercontent.com/drewbarontini/noise/master/#{ @config_file }"

# -------------------------------------
#   Methods
# -------------------------------------

def is_cli_installed?
  Dir.exists? @cli_directory
end

def is_config_present?
  File.exists? @config_file
end

def install_cli
  puts 'Installing sass-lint via NPM...'
  system 'npm install -g sass-lint'
end

def configure
  system "curl -s #{ @config_file_path } >> #{ @config_file }"
end

def run
  ARGV.each do |path|
    system "sass-lint '#{ path }' -c #{ @config_file } -vq"
  end
end

# -------------------------------------
#   Sequence
# -------------------------------------

install_cli unless is_cli_installed?
configure   unless is_config_present?

run

When we type sass-linter path/to/stylsheet/*.sass in a project, the linter will perform all the necessary setup steps and run. This was a small change, but had a huge impact on our workflow.

That’s All, Folks

Spend time to identify potential problems in your workflow, research the problem to find a solution, and work to build an automation solution to increase your workflow automation and efficiency.