Search code examples
javascriptnode.jsgoogle-app-enginegoogle-api-nodejs-client

Why does Google use backticks or "template literals" in these NodeJS require functions?


See the code below from lines 14-20 of this GitHub file. Why does Google use backticks or "template literals" in the require functions, instead of regular single or double quotes?

The code is from a testing script in Google's tutorial for using NodeJS on AppEngine. I researched template literals and the require function but could not find any resource explaining why one would use template literals in a require statement, or what effect it would have.

'use strict';

const testConfig = require(`./_test-config`);
const proxyquire = require(`proxyquire`).noPreserveCache();
const sinon = require(`sinon`);
const test = require(`ava`);
const utils = require(`@google-cloud/nodejs-repo-tools`);

Solution

  • Yeah I'm going to be honest here - there was really no good reason. Template literals are great if youre doing string interpolation, but in this case it's likely unnecessary.