static async _getCodeArchive(codeDir) {
    const stats = await fs.stat(codeDir);
    if (stats.isDirectory()) {
      const os = require('os');
      const path = require('path');
      const basename = path.basename(codeDir);
      const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), '/'));
      const tarfile = path.join(tmpdir, `${basename}.tar`);

      return new Promise((resolve, reject) => {
        const output = fs.createWriteStream(tarfile, { encoding: 'utf-8' });
        output.on('close', () => {
          resolve(tarfile);
        });

        const archive = require('archiver')('tar');
        archive.on('error', (err) => {
          console.error('Taring code archive failed: %s', codeDir);
          reject(err);
        });
        archive.pipe(output);
        archive.directory(codeDir, '');
        archive.finalize();
      });
    }
    throw new Error(`Not a directory at ${codeDir}.`);
  }
Tar the code into a file. Return the path of the tar file.

@param codeDir the directory of the code, which is a absolute one.
@returns {Promise} the promise to get the path of the tar file.
@private