Skip to content

Commit

Permalink
choir(lodash@4): compatibility blues, replace _.any with _.some & add…
Browse files Browse the repository at this point in the history
… a warning for loading the wrong lodash version.
  • Loading branch information
anodynos committed May 24, 2016
1 parent b121a89 commit 4f0b891
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.28pre",
"version": "0.7.0-beta.28",
"homepage": "http://uRequire.org",
"author": {
"name": "Agelos Pikoulas",
Expand Down Expand Up @@ -85,7 +85,7 @@
"mocha": "2.4.x",
"teacup": "0.4.x",
"urequire": "0.7.0-beta.27",
"urequire-ab-specrunner": "^0.2.4",
"urequire-ab-specrunner": "^0.2.5",
"urequire-rc-exec": "^0.1.2",
"urequire-rc-import-keys": "^0.1.4",
"urequire-rc-inject-version": "^0.1.6",
Expand Down
4 changes: 2 additions & 2 deletions source/code/codeUtils/CodeMerger.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CodeMerger
addbodyNode: (node) ->
if node.type is 'VariableDeclaration'
for decl in node.declarations
if not _.any(@declarations, (fd) -> _.isEqual decl, fd)
if not _.some(@declarations, (fd) -> _.isEqual decl, fd)
if dublicateDecl = _.find(@declarations, (fd) -> isLikeCode {type:decl.type, id:decl.id}, fd)
if @options.uniqueDeclarations
throw new UError """
Expand All @@ -40,7 +40,7 @@ class CodeMerger
l.debug 90, "Adding declaration of '#{decl.id.name}'"
@declarations.push decl
else
if not _.any(@statements, (fd) -> _.isEqual node, fd)
if not _.some(@statements, (fd) -> _.isEqual node, fd)
@statements.push node

null
Expand Down
2 changes: 1 addition & 1 deletion source/code/fileResources/Module.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ class Module extends TextResource
# plus those without params AND not present as require('depX') #todo: simplify in @adjust
if @defineArrayDeps
for remainingDep in @defineArrayDeps[@parameters?.length..@defineArrayDeps.length-1]
if not _.any((@ext_requireDeps or []), (rdep) -> rdep.isEqual remainingDep)
if not _.some((@ext_requireDeps or []), (rdep) -> rdep.isEqual remainingDep)
nds.push remainingDep
nds

Expand Down
2 changes: 1 addition & 1 deletion source/code/process/Build.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = class Build extends _B.CalcCachedProperties
*
* #{ pkg?.description }
* Version #{ pkg?.version } - Compiled on #{ moment().format("YYYY-MM-DD HH:mm:ss") }
* Repository #{ pkg?.repository?.url }
* Repository #{ pkg?.repository?.url or pkg?.repository }
* Copyright(c) #{ moment().format("YYYY") } #{
if _.isString pkg.author
pkg.author
Expand Down
4 changes: 2 additions & 2 deletions source/code/templates/ModuleGeneratorTemplates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ModuleGeneratorTemplates extends Template
# even if defineArrayDeps is empty
allowEmptyDefineDepsArray =
_.isEmpty(@module.defineArrayDeps) and @isScanAllow and
(not _.any @module.ext_requireDeps, (d) -> d.isNode)
(not _.some @module.ext_requireDeps, (d) -> d.isNode)

( if allowEmptyDefineDepsArray
""
Expand Down Expand Up @@ -262,7 +262,7 @@ class ModuleGeneratorTemplates extends Template
@_genFullBody( # load AMD deps 1st, before kicking off common dynamic code

# deps with a variable (parameter in AMD)
( if _.any(nodeDeps,
( if _.some(nodeDeps,
(dep, depIdx)=> (not dep.isSystem) and (@module?.parameters or [])[depIdx]) # has a dep with param
"\nvar "
else
Expand Down
4 changes: 4 additions & 0 deletions source/code/urequire.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ fs = require 'fsp'

_.mixin require('underscore.string').exports()

if not _.startsWith _.VERSION, '3'
l.warn """uRequire v#{exports.VERSION} should load lodash@3.x as its specified in its `dependencies`, but instead it seems to be** using #{_.VERSION}.
Blame npm@3 & how it treats node_modules. Drop me a message if you know to fix this."""

require 'coffee-script/register'

Object.defineProperties exports, # lazily export
Expand Down
6 changes: 3 additions & 3 deletions source/spec/fileResources/Dependency-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ untrust = (indexes, depsStrings) ->
depsStrings

describe "Dependency:", ->

describe "init & and extracting data:", ->

it "split plugin, extension, resourceName & recostruct as String", ->
Expand Down Expand Up @@ -206,7 +206,7 @@ describe "Dependency:", ->
it "matches alike", ->
[dep1, dep2, dep3].forEach (dep) ->
tru dep.isEqual 'rootdir/dep'

describe "plugins still matter:", ->
it "they make a difference", ->
[dep1, dep2, dep3].forEach (dep) ->
Expand Down Expand Up @@ -253,7 +253,7 @@ describe "Dependency:", ->

it "looking for one in an array", ->
dependencies = [dep1, dep2, depPlugin]
tru (_.any dependencies, (dep) -> dep.isEqual 'rootdir/dep.js')
tru (_.some dependencies, (dep) -> dep.isEqual 'rootdir/dep.js')

describe "resolving all types bundle/file relative, external, local, notFound, webRootMap:", ->
mod =
Expand Down

0 comments on commit 4f0b891

Please sign in to comment.