Skip to content

Commit

Permalink
attach ` ['CodeMerger', 'isEqualCode', 'isLikeCode', 'replaceCode', '…
Browse files Browse the repository at this point in the history
…toAST', 'toCode', 'blendConfigs']` to urequire
  • Loading branch information
anodynos committed Jan 24, 2016
1 parent d73718b commit d8a4022
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
7 changes: 4 additions & 3 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "urequire",
"description": "Convert AMD & commonjs modules to UMD, AMD, commonjs or `combined.js` (rjs & almond) & run/test on nodejs, Web/AMD or Web/Script. Manipulate & inject module code & dependencies while building & more",
"version": "0.7.0-beta.24",
"version": "0.7.0-beta.25",
"homepage": "http://uRequire.org",
"author": {
"name": "Agelos Pikoulas",
Expand Down Expand Up @@ -44,7 +44,7 @@
"dist": "./build"
},
"engines": {
"node": ">=0.10.0 <=5.x"
"node": ">=0.10.0 <=4.x"
},
"dependencies": {
"almond": "0.3.x",
Expand Down Expand Up @@ -84,8 +84,9 @@
"urequire-rc-exec": "0.1.x",
"urequire-rc-less": "0.1.x",
"urequire-rc-teacup-js": "0.2.x",
"urequire-rc-teacup-js2html": "0.2.x",
"teacup": "0.4.x",
"urequire": "0.7.0-beta.23",
"urequire": "0.7.0-beta.24",
"urequire-ab-specrunner": "~0.2.1",
"urequire-rc-inject-version": "~0.1.5",
"urequire-rc-import-keys": "~0.1.2"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
@@ -1,4 +1,4 @@
# uRequire v0.7.0-beta.24
# uRequire v0.7.0-beta.25

## Beta release note

Expand Down
68 changes: 37 additions & 31 deletions source/code/urequire.coffee
Expand Up @@ -27,47 +27,53 @@ Object.defineProperties exports, # lazily export
BBExecuted: get:-> BBExecuted
BBCreated: get:-> BBCreated


_.each ['CodeMerger', 'isEqualCode', 'isLikeCode', 'replaceCode', 'toAST', 'toCode'], (codeUtil)->
Object.defineProperty exports, codeUtil, get: -> require './codeUtils/' + codeUtil

BBExecuted = []
BBCreated = []

exports.addBBCreated = (bb)->
if bb.build.target and exports.findBBCreated(bb.build.target)
throw new UError "Can't have two BundleBuilders with the same `target` '#{bb.build.target}'"
BBCreated.push bb
_.extend exports,

exports.findBBCreated = (target)->
_.find BBCreated, (bb)-> bb.build.target is target
addBBCreated: (bb)->
if bb.build.target and exports.findBBCreated(bb.build.target)
throw new UError "Can't have two BundleBuilders with the same `target` '#{bb.build.target}'"
BBCreated.push bb

exports.addBBExecuted = (bb)->
_.pull BBExecuted, bb # mutate existing array
BBExecuted.push bb
findBBCreated: (target)->
_.find BBCreated, (bb)-> bb.build.target is target

exports.findBBExecutedLast = (target)->
if _.isUndefined(target) or _.isNull(target)
_.last BBExecuted
else
if _.isString target
_.findLast BBExecuted, (bb)-> bb.build.target is target
else
throw new Error "urequire: findBBExecutedLast() unknown parameter type `#{_B.type target}`, target argument = #{target}"

exports.findBBExecutedBefore = (bbOrTarget)->
if _.isUndefined(bbOrTarget) or _.isNull(bbOrTarget)
_.last BBExecuted
else
if _.isString bbOrTarget
li = _.findLastIndex BBExecuted, (bb)-> bb.build.target is bbOrTarget
addBBExecuted: (bb)->
_.pull BBExecuted, bb # mutate existing array
BBExecuted.push bb

findBBExecutedLast: (target)->
if _.isUndefined(target) or _.isNull(target)
_.last BBExecuted
else
if bbOrTarget instanceof require("./process/BundleBuilder")
li = _.lastIndexOf BBExecuted, bbOrTarget
if _.isString target
_.findLast BBExecuted, (bb)-> bb.build.target is target
else
throw new Error "urequire: findBBExecutedBefore() unknown parameter type `#{_B.type bbOrTarget}`, bbOrTarget argument = #{bbOrTarget}"
throw new Error "urequire: findBBExecutedLast() unknown parameter type `#{_B.type target}`, target argument = #{target}"

if li >= 1
BBExecuted[li-1]
findBBExecutedBefore: (bbOrTarget)->
if _.isUndefined(bbOrTarget) or _.isNull(bbOrTarget)
_.last BBExecuted
else
null
if _.isString bbOrTarget
li = _.findLastIndex BBExecuted, (bb)-> bb.build.target is bbOrTarget
else
if bbOrTarget instanceof require("./process/BundleBuilder")
li = _.lastIndexOf BBExecuted, bbOrTarget
else
throw new Error "urequire: findBBExecutedBefore() unknown parameter type `#{_B.type bbOrTarget}`, bbOrTarget argument = #{bbOrTarget}"

if li >= 1
BBExecuted[li-1]
else
null

blendConfigs = require('./config/blendConfigs')
blendConfigs = exports.blendConfigs = require './config/blendConfigs'
for b in ['dependenciesBindingsBlender', 'templateBlender', 'shimBlender', 'watchBlender']
exports[b] = blendConfigs[b]

0 comments on commit d8a4022

Please sign in to comment.