code: function validate(dname) {
      var filenames = glob.sync(dname + '/src/*.ts*');
      filenames = filenames.concat(glob.sync(dname + '/src/**/*.ts*'));
  
      if (filenames.length == 0) {
          return [];
      }
  
      var imports = [];
  
      try {
          var pkg = require(path.resolve(dname) + '/package.json');
      } catch (e) {
          return [];
      }
      var ignore = IGNORE[pkg['name']] || [];
      var deps = pkg['dependencies'];
  
      // Extract all of the imports from the TypeScript files.
      filenames.forEach(fileName => {
          var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
          imports = imports.concat(getImports(sourceFile));
          //console.log(fileName, getImports(sourceFile));
      });
      var names = Array.from(new Set(imports)).sort();
      names = names.map(function(name) {
          var parts = name.split('/');
          if (name.indexOf('@') === 0) {
              return parts[0] + '/' + parts[1];
          }
          return parts[0];
      })
  
      var problems = [];
      names.forEach(function(name) {
          if (name === '..' || name === '.' || ignore.indexOf(name) !== -1) {
              return;
          }
          if (!deps[name]) {
              problems.push('Missing package: ' + name);
          }
      });
      Object.keys(deps).forEach(function(name) {
          if (versions[name]) {
              var desired = '^' + versions[name];
              if (deps[name] !== desired) {
                  problems.push('Bad core version: ' + name + ' should be ' + desired);
              }
          }
          if (ignore.indexOf(name) !== -1) {
              return;
          }
          if (names.indexOf(name) === -1) {
              problems.push('Unused package: ' + name);
          }
      });
      return problems;
  }
docs: Validate the integrity of a package in a directory.