我有这个coffeescript函数:
_skip_version = (currentVersion, skippedVersions) ->
if (currentVersion.indexOf(skippedVersions) == -1)
return false
return true
它当前在我的archive.spec.coffee
文件中,其调用方式如下:
if (_skip_version(config.version, version))
this.skip 'Skipping test - Not supported on this version'
我现在希望其他文件使用_skip_version
,因此archive.spec.coffee
似乎不再是保留它的地方。我想将其移至helpers.coffee
。我将函数复制到新文件,并将helpers = require('./helpers')
添加到archive.spec.coffee
。现在,我试图这样称呼它:
if (helpers._skip_version(s3.config.clevOsVersion, version))
this.skip 'Skipping test - Not supported on this version'
它抛出此错误:
TypeError: helpers._skip_version is not a function
我做错了什么?
这是我的hooks.coffee
文件:
AWS = null
global = null
if typeof window == 'undefined'
AWS = require 'aws-sdk'
global = GLOBAL
else
AWS = window.AWS
global = window
if global.jasmine
global.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000
require('util').print = (data) ->
process.stdout.write(data)
global.expect = require('chai').expect
matchXML = (xml1, xml2) ->
results = []
parser = new (require('xml2js').Parser)()
[xml1, xml2].forEach (xml) ->
parser.parseString xml, (e, r) ->
if e then throw e
results.push(r)
expect(results[0]).to.eql(results[1])
getUniqueName = ->
'aws-' + Date.now()
_skip_version = (currentVersion, skippedVersions) ->
if (currentVersion.indexOf(skippedVersions) == -1)
return false
return true
module.exports =
AWS: AWS
util: AWS.util
getUniqueName: getUniqueName
matchXML: matchXML
答案 0 :(得分:1)
您不导出
更改
module.exports =
AWS: AWS
util: AWS.util
getUniqueName: getUniqueName
matchXML: matchXML
收件人
module.exports =
AWS: AWS
util: AWS.util
getUniqueName: getUniqueName
matchXML: matchXML
_skip_version: _skip_version