Merge pull request #13460 from atom/mkt-transpile-packages-during-tests

Use package-specific transpilation options during tests
This commit is contained in:
Michelle Tilley
2016-12-20 08:08:34 -08:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ module.exports = ({blobStore}) ->
path = require 'path'
{ipcRenderer} = require 'electron'
{getWindowLoadSettings} = require './window-load-settings-helpers'
CompileCache = require './compile-cache'
AtomEnvironment = require '../src/atom-environment'
ApplicationDelegate = require '../src/application-delegate'
Clipboard = require '../src/clipboard'
@@ -58,6 +59,13 @@ module.exports = ({blobStore}) ->
require('module').globalPaths.push(exportsPath)
process.env.NODE_PATH = exportsPath # Set NODE_PATH env variable since tasks may need it.
# Set up optional transpilation for packages under test if any
FindParentDir = require 'find-parent-dir'
if packageRoot = FindParentDir.sync(testPaths[0], 'package.json')
packageMetadata = require(path.join(packageRoot, 'package.json'))
if packageMetadata.atomTranspilers
CompileCache.addTranspilerConfigForPath(packageRoot, packageMetadata.name, packageMetadata, packageMetadata.atomTranspilers)
document.title = "Spec Suite"
clipboard = new Clipboard

View File

@@ -74,7 +74,13 @@ class NativeCompileCache {
self.cacheStore.delete(cacheKey)
}
} else {
let compilationResult = cachedVm.runInThisContext(wrapper, filename)
let compilationResult
try {
compilationResult = cachedVm.runInThisContext(wrapper, filename)
} catch (err) {
console.error(`Error running script ${filename}`)
throw err
}
if (compilationResult.cacheBuffer) {
self.cacheStore.set(cacheKey, invalidationKey, compilationResult.cacheBuffer)
}