From 5235114eed2f53d0aa58e23e616b3f76f58899d4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 14 Aug 2013 11:26:19 -0700 Subject: [PATCH] Use fs.readdirSync() for listing package directories Previously fsUtils.listTreeSync() was used which returns every path in the tree, not just paths directly underneath the root path. This speeds up the spec suite require time by not stat'ing the entire node_modules directory. --- spec/spec-suite.coffee | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index c8a94c208..356c627eb 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -1,3 +1,5 @@ +fs = require 'fs' + require 'window' measure 'spec suite require time', -> @@ -18,11 +20,14 @@ measure 'spec suite require time', -> setSpecType('core') # Run bundled package specs - for packagePath in fsUtils.listTreeSync(config.nodeModulesDirPath) when atom.isInternalPackage(packagePath) - requireSpecs(packagePath, 'bundled') - setSpecType('bundled') + if fsUtils.isDirectorySync(config.nodeModulesDirPath) + for packageName in fs.readdirSync(config.nodeModulesDirPath) + packagePath = path.join(config.nodeModulesDirPath, packageName) + requireSpecs(packagePath, 'bundled') if atom.isInternalPackage(packagePath) + setSpecType('bundled') # Run user package specs - for packagePath in fsUtils.listTreeSync(config.userPackagesDirPath) - requireSpecs(packagePath, 'user') - setSpecType('user') + if fsUtils.isDirectorySync(config.userPackagesDirPath) + for packageName in fs.readdirSync(config.userPackagesDirPath) + requireSpecs(path.join(config.userPackagesDirPath, packageName)) + setSpecType('user')