From ea7a7997a778ccf0edace13f3908782c1f79b1ba Mon Sep 17 00:00:00 2001 From: christianesperar Date: Tue, 10 May 2016 23:27:55 +0800 Subject: [PATCH] Remove update package --- vendors/update/.bower.json | 14 - vendors/update/.editorconfig | 22 - vendors/update/.eslintrc.json | 278 ---- vendors/update/.gitattributes | 10 - vendors/update/.gitignore | 15 - vendors/update/.travis.yml | 12 - vendors/update/.verb.md | 147 --- vendors/update/LICENSE | 21 - vendors/update/README.md | 185 --- vendors/update/bin/update.js | 38 - vendors/update/gulpfile.js | 27 - vendors/update/index.js | 169 --- vendors/update/lib/config.js | 30 - vendors/update/lib/locals.js | 26 - vendors/update/lib/middleware/index.js | 1 - vendors/update/lib/middleware/json.js | 22 - vendors/update/lib/runner/argv.js | 55 - vendors/update/lib/runner/decorate.js | 39 - vendors/update/lib/runner/env.js | 53 - vendors/update/lib/runner/list.js | 40 - vendors/update/lib/runner/listen.js | 30 - vendors/update/lib/runner/run.js | 46 - vendors/update/lib/runner/runner.js | 107 -- vendors/update/lib/runner/updater.js | 127 -- vendors/update/lib/tasks/default.js | 5 - vendors/update/lib/tasks/del.js | 17 - vendors/update/lib/tasks/dest.js | 29 - vendors/update/lib/tasks/files.js | 24 - vendors/update/lib/tasks/index.js | 1 - vendors/update/lib/tasks/lint.js | 18 - vendors/update/lib/tasks/list.js | 10 - vendors/update/lib/tasks/noop.js | 7 - vendors/update/lib/tasks/rename.js | 65 - vendors/update/lib/tasks/tree.js | 10 - vendors/update/lib/utils.js | 329 ----- vendors/update/package.json | 155 --- vendors/update/test/app.applyLayout.js | 87 -- vendors/update/test/app.collection.compile.js | 50 - vendors/update/test/app.collection.js | 186 --- vendors/update/test/app.collection.render.js | 157 --- vendors/update/test/app.compile.js | 52 - vendors/update/test/app.copy.js | 31 - vendors/update/test/app.create.js | 244 ---- vendors/update/test/app.data.js | 94 -- vendors/update/test/app.dest.js | 1103 ---------------- vendors/update/test/app.engines.js | 160 --- vendors/update/test/app.events.js | 113 -- vendors/update/test/app.get-set.js | 72 -- vendors/update/test/app.handle.js | 37 - vendors/update/test/app.handlers.js | 72 -- vendors/update/test/app.js | 130 -- vendors/update/test/app.list.compile.js | 44 - vendors/update/test/app.list.js | 111 -- vendors/update/test/app.lookups.js | 112 -- vendors/update/test/app.middleware.js | 60 - vendors/update/test/app.onLoad.js | 48 - vendors/update/test/app.option.js | 98 -- vendors/update/test/app.render.js | 88 -- vendors/update/test/app.renderFile.js | 135 -- vendors/update/test/app.route.js | 93 -- vendors/update/test/app.src.js | 295 ----- vendors/update/test/app.symlink.js | 396 ------ vendors/update/test/app.task.js | 159 --- vendors/update/test/app.toStream.js | 64 - vendors/update/test/app.use.js | 281 ---- vendors/update/test/app.view.compile.js | 38 - vendors/update/test/app.view.render.js | 92 -- vendors/update/test/app.watch.js | 42 - vendors/update/test/collection.engines.js | 176 --- vendors/update/test/collection.events.js | 27 - vendors/update/test/collection.getView.js | 34 - vendors/update/test/collection.js | 540 -------- vendors/update/test/collection.options.js | 25 - vendors/update/test/collection.render.js | 138 -- vendors/update/test/collection.use.js | 156 --- vendors/update/test/fixtures/bom-utf16be.txt | Bin 244 -> 0 bytes vendors/update/test/fixtures/bom-utf16le.txt | Bin 244 -> 0 bytes vendors/update/test/fixtures/bom-utf8.txt | 1 - vendors/update/test/fixtures/copy/a.txt | 1 - vendors/update/test/fixtures/copy/b.txt | 1 - vendors/update/test/fixtures/copy/c.txt | 1 - vendors/update/test/fixtures/copy/example.txt | 1 - vendors/update/test/fixtures/data/a.json | 3 - vendors/update/test/fixtures/data/alert.json | 7 - vendors/update/test/fixtures/data/b.json | 3 - vendors/update/test/fixtures/data/c.json | 3 - vendors/update/test/fixtures/data/data.json | 3 - vendors/update/test/fixtures/data/test.json | 4 - vendors/update/test/fixtures/example.txt | 1 - .../front-matter/autodetect-no-lang.md | 5 - .../fixtures/front-matter/autodetect-yaml.md | 5 - .../test/fixtures/front-matter/lang-yaml.md | 5 - vendors/update/test/fixtures/generic/run.dmc | 1 - vendors/update/test/fixtures/generic/test.dmc | 1 - vendors/update/test/fixtures/helpers/a.js | 3 - vendors/update/test/fixtures/helpers/b.js | 3 - vendors/update/test/fixtures/helpers/c.js | 3 - vendors/update/test/fixtures/helpers/obj.js | 9 - vendors/update/test/fixtures/noext/license | 21 - vendors/update/test/fixtures/pages/a.hbs | 2 - vendors/update/test/fixtures/pages/b.hbs | 2 - vendors/update/test/fixtures/pages/c.hbs | 2 - vendors/update/test/fixtures/pipeline/a.js | 19 - vendors/update/test/fixtures/pipeline/b.js | 14 - vendors/update/test/fixtures/pipeline/c.js | 14 - vendors/update/test/fixtures/pipeline/d.js | 14 - vendors/update/test/fixtures/posts/a.txt | 4 - vendors/update/test/fixtures/posts/b.txt | 4 - vendors/update/test/fixtures/posts/c.txt | 4 - vendors/update/test/fixtures/templates/a.tmpl | 1 - vendors/update/test/fixtures/templates/b.tmpl | 1 - vendors/update/test/fixtures/templates/c.tmpl | 1 - .../test/fixtures/test-symlink-dir/suchempty | 1 - vendors/update/test/fixtures/test.coffee | 1 - vendors/update/test/fixtures/updaters/a.txt | 1 - vendors/update/test/fixtures/updaters/b.txt | 1 - vendors/update/test/fixtures/updaters/c.txt | 1 - .../test/fixtures/vinyl/bom-utf16be.txt | Bin 244 -> 0 bytes .../test/fixtures/vinyl/bom-utf16le.txt | Bin 244 -> 0 bytes .../update/test/fixtures/vinyl/bom-utf8.txt | 1 - .../update/test/fixtures/vinyl/test.coffee | 1 - .../update/test/fixtures/vinyl/wow/suchempty | 1 - vendors/update/test/fixtures/watch/test.txt | 1 - vendors/update/test/fixtures/wow/suchempty | 1 - vendors/update/test/group.js | 144 --- vendors/update/test/handlers.js | 46 - vendors/update/test/helpers.js | 800 ------------ vendors/update/test/item.js | 1060 --------------- vendors/update/test/layouts.js | 127 -- vendors/update/test/list.js | 689 ---------- vendors/update/test/list.render.js | 137 -- vendors/update/test/list.use.js | 156 --- vendors/update/test/mergePartials.js | 104 -- vendors/update/test/partials.js | 202 --- vendors/update/test/questions.js | 58 - vendors/update/test/renameKey.js | 350 ----- vendors/update/test/render.js | 72 -- vendors/update/test/routes.js | 98 -- vendors/update/test/store.js | 243 ---- vendors/update/test/support/ignore.js | 6 - vendors/update/test/support/index.js | 64 - vendors/update/test/support/spy.js | 27 - vendors/update/test/view.content.js | 29 - vendors/update/test/view.events.js | 28 - vendors/update/test/view.js | 1148 ----------------- vendors/update/test/view.methods.js | 39 - vendors/update/test/view.option.js | 29 - vendors/update/test/view.render.js | 52 - vendors/update/test/view.set.js | 34 - vendors/update/test/view.use.js | 60 - vendors/update/test/viewTypes.js | 52 - vendors/update/test/views.js | 525 -------- vendors/update/test/views.use.js | 156 --- vendors/update/updatefile.js | 7 - 154 files changed, 14743 deletions(-) delete mode 100644 vendors/update/.bower.json delete mode 100644 vendors/update/.editorconfig delete mode 100644 vendors/update/.eslintrc.json delete mode 100644 vendors/update/.gitattributes delete mode 100644 vendors/update/.gitignore delete mode 100644 vendors/update/.travis.yml delete mode 100644 vendors/update/.verb.md delete mode 100644 vendors/update/LICENSE delete mode 100644 vendors/update/README.md delete mode 100755 vendors/update/bin/update.js delete mode 100644 vendors/update/gulpfile.js delete mode 100644 vendors/update/index.js delete mode 100644 vendors/update/lib/config.js delete mode 100644 vendors/update/lib/locals.js delete mode 100644 vendors/update/lib/middleware/index.js delete mode 100644 vendors/update/lib/middleware/json.js delete mode 100644 vendors/update/lib/runner/argv.js delete mode 100644 vendors/update/lib/runner/decorate.js delete mode 100644 vendors/update/lib/runner/env.js delete mode 100644 vendors/update/lib/runner/list.js delete mode 100644 vendors/update/lib/runner/listen.js delete mode 100644 vendors/update/lib/runner/run.js delete mode 100644 vendors/update/lib/runner/runner.js delete mode 100644 vendors/update/lib/runner/updater.js delete mode 100644 vendors/update/lib/tasks/default.js delete mode 100644 vendors/update/lib/tasks/del.js delete mode 100644 vendors/update/lib/tasks/dest.js delete mode 100644 vendors/update/lib/tasks/files.js delete mode 100644 vendors/update/lib/tasks/index.js delete mode 100644 vendors/update/lib/tasks/lint.js delete mode 100644 vendors/update/lib/tasks/list.js delete mode 100644 vendors/update/lib/tasks/noop.js delete mode 100644 vendors/update/lib/tasks/rename.js delete mode 100644 vendors/update/lib/tasks/tree.js delete mode 100644 vendors/update/lib/utils.js delete mode 100644 vendors/update/package.json delete mode 100644 vendors/update/test/app.applyLayout.js delete mode 100644 vendors/update/test/app.collection.compile.js delete mode 100644 vendors/update/test/app.collection.js delete mode 100644 vendors/update/test/app.collection.render.js delete mode 100644 vendors/update/test/app.compile.js delete mode 100644 vendors/update/test/app.copy.js delete mode 100644 vendors/update/test/app.create.js delete mode 100644 vendors/update/test/app.data.js delete mode 100644 vendors/update/test/app.dest.js delete mode 100644 vendors/update/test/app.engines.js delete mode 100644 vendors/update/test/app.events.js delete mode 100644 vendors/update/test/app.get-set.js delete mode 100644 vendors/update/test/app.handle.js delete mode 100644 vendors/update/test/app.handlers.js delete mode 100644 vendors/update/test/app.js delete mode 100644 vendors/update/test/app.list.compile.js delete mode 100644 vendors/update/test/app.list.js delete mode 100644 vendors/update/test/app.lookups.js delete mode 100644 vendors/update/test/app.middleware.js delete mode 100644 vendors/update/test/app.onLoad.js delete mode 100644 vendors/update/test/app.option.js delete mode 100644 vendors/update/test/app.render.js delete mode 100644 vendors/update/test/app.renderFile.js delete mode 100644 vendors/update/test/app.route.js delete mode 100644 vendors/update/test/app.src.js delete mode 100644 vendors/update/test/app.symlink.js delete mode 100644 vendors/update/test/app.task.js delete mode 100644 vendors/update/test/app.toStream.js delete mode 100644 vendors/update/test/app.use.js delete mode 100644 vendors/update/test/app.view.compile.js delete mode 100644 vendors/update/test/app.view.render.js delete mode 100644 vendors/update/test/app.watch.js delete mode 100644 vendors/update/test/collection.engines.js delete mode 100644 vendors/update/test/collection.events.js delete mode 100644 vendors/update/test/collection.getView.js delete mode 100644 vendors/update/test/collection.js delete mode 100644 vendors/update/test/collection.options.js delete mode 100644 vendors/update/test/collection.render.js delete mode 100644 vendors/update/test/collection.use.js delete mode 100644 vendors/update/test/fixtures/bom-utf16be.txt delete mode 100644 vendors/update/test/fixtures/bom-utf16le.txt delete mode 100644 vendors/update/test/fixtures/bom-utf8.txt delete mode 100644 vendors/update/test/fixtures/copy/a.txt delete mode 100644 vendors/update/test/fixtures/copy/b.txt delete mode 100644 vendors/update/test/fixtures/copy/c.txt delete mode 100644 vendors/update/test/fixtures/copy/example.txt delete mode 100644 vendors/update/test/fixtures/data/a.json delete mode 100644 vendors/update/test/fixtures/data/alert.json delete mode 100644 vendors/update/test/fixtures/data/b.json delete mode 100644 vendors/update/test/fixtures/data/c.json delete mode 100644 vendors/update/test/fixtures/data/data.json delete mode 100644 vendors/update/test/fixtures/data/test.json delete mode 100644 vendors/update/test/fixtures/example.txt delete mode 100644 vendors/update/test/fixtures/front-matter/autodetect-no-lang.md delete mode 100644 vendors/update/test/fixtures/front-matter/autodetect-yaml.md delete mode 100644 vendors/update/test/fixtures/front-matter/lang-yaml.md delete mode 100644 vendors/update/test/fixtures/generic/run.dmc delete mode 100644 vendors/update/test/fixtures/generic/test.dmc delete mode 100644 vendors/update/test/fixtures/helpers/a.js delete mode 100644 vendors/update/test/fixtures/helpers/b.js delete mode 100644 vendors/update/test/fixtures/helpers/c.js delete mode 100644 vendors/update/test/fixtures/helpers/obj.js delete mode 100644 vendors/update/test/fixtures/noext/license delete mode 100644 vendors/update/test/fixtures/pages/a.hbs delete mode 100644 vendors/update/test/fixtures/pages/b.hbs delete mode 100644 vendors/update/test/fixtures/pages/c.hbs delete mode 100644 vendors/update/test/fixtures/pipeline/a.js delete mode 100644 vendors/update/test/fixtures/pipeline/b.js delete mode 100644 vendors/update/test/fixtures/pipeline/c.js delete mode 100644 vendors/update/test/fixtures/pipeline/d.js delete mode 100644 vendors/update/test/fixtures/posts/a.txt delete mode 100644 vendors/update/test/fixtures/posts/b.txt delete mode 100644 vendors/update/test/fixtures/posts/c.txt delete mode 100644 vendors/update/test/fixtures/templates/a.tmpl delete mode 100644 vendors/update/test/fixtures/templates/b.tmpl delete mode 100644 vendors/update/test/fixtures/templates/c.tmpl delete mode 100644 vendors/update/test/fixtures/test-symlink-dir/suchempty delete mode 100644 vendors/update/test/fixtures/test.coffee delete mode 100644 vendors/update/test/fixtures/updaters/a.txt delete mode 100644 vendors/update/test/fixtures/updaters/b.txt delete mode 100644 vendors/update/test/fixtures/updaters/c.txt delete mode 100644 vendors/update/test/fixtures/vinyl/bom-utf16be.txt delete mode 100644 vendors/update/test/fixtures/vinyl/bom-utf16le.txt delete mode 100644 vendors/update/test/fixtures/vinyl/bom-utf8.txt delete mode 100644 vendors/update/test/fixtures/vinyl/test.coffee delete mode 100644 vendors/update/test/fixtures/vinyl/wow/suchempty delete mode 100644 vendors/update/test/fixtures/watch/test.txt delete mode 100644 vendors/update/test/fixtures/wow/suchempty delete mode 100644 vendors/update/test/group.js delete mode 100644 vendors/update/test/handlers.js delete mode 100644 vendors/update/test/helpers.js delete mode 100644 vendors/update/test/item.js delete mode 100644 vendors/update/test/layouts.js delete mode 100644 vendors/update/test/list.js delete mode 100644 vendors/update/test/list.render.js delete mode 100644 vendors/update/test/list.use.js delete mode 100644 vendors/update/test/mergePartials.js delete mode 100644 vendors/update/test/partials.js delete mode 100644 vendors/update/test/questions.js delete mode 100644 vendors/update/test/renameKey.js delete mode 100644 vendors/update/test/render.js delete mode 100644 vendors/update/test/routes.js delete mode 100644 vendors/update/test/store.js delete mode 100644 vendors/update/test/support/ignore.js delete mode 100644 vendors/update/test/support/index.js delete mode 100644 vendors/update/test/support/spy.js delete mode 100644 vendors/update/test/view.content.js delete mode 100644 vendors/update/test/view.events.js delete mode 100644 vendors/update/test/view.js delete mode 100644 vendors/update/test/view.methods.js delete mode 100644 vendors/update/test/view.option.js delete mode 100644 vendors/update/test/view.render.js delete mode 100644 vendors/update/test/view.set.js delete mode 100644 vendors/update/test/view.use.js delete mode 100644 vendors/update/test/viewTypes.js delete mode 100644 vendors/update/test/views.js delete mode 100644 vendors/update/test/views.use.js delete mode 100644 vendors/update/updatefile.js diff --git a/vendors/update/.bower.json b/vendors/update/.bower.json deleted file mode 100644 index a6775382..00000000 --- a/vendors/update/.bower.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "update", - "homepage": "https://github.com/jonschlinkert/update", - "_release": "cf42344639", - "_resolution": { - "type": "branch", - "branch": "master", - "commit": "cf423446393d68666c9f591b8eee7458191cea45" - }, - "_source": "https://github.com/jonschlinkert/update.git", - "_target": "*", - "_originalSource": "update", - "_direct": true -} \ No newline at end of file diff --git a/vendors/update/.editorconfig b/vendors/update/.editorconfig deleted file mode 100644 index 991900b7..00000000 --- a/vendors/update/.editorconfig +++ /dev/null @@ -1,22 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = space -end_of_line = lf -charset = utf-8 -indent_size = 2 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false -insert_final_newline = false - -[test/**] -trim_trailing_whitespace = false -insert_final_newline = false - -[templates/**] -trim_trailing_whitespace = false -insert_final_newline = false diff --git a/vendors/update/.eslintrc.json b/vendors/update/.eslintrc.json deleted file mode 100644 index cc6a8679..00000000 --- a/vendors/update/.eslintrc.json +++ /dev/null @@ -1,278 +0,0 @@ -{ - "ecmaFeatures": { - "modules": true, - "experimentalObjectRestSpread": true - }, - "env": { - "browser": false, - "es6": true, - "node": true, - "mocha": true - }, - "globals": { - "document": false, - "navigator": false, - "window": false - }, - "rules": { - "accessor-pairs": 2, - "arrow-spacing": [ - 2, - { - "before": true, - "after": true - } - ], - "block-spacing": [ - 2, - "always" - ], - "brace-style": [ - 2, - "1tbs", - { - "allowSingleLine": true - } - ], - "comma-dangle": [ - 2, - "never" - ], - "comma-spacing": [ - 2, - { - "before": false, - "after": true - } - ], - "comma-style": [ - 2, - "last" - ], - "constructor-super": 2, - "curly": [ - 2, - "multi-line" - ], - "dot-location": [ - 2, - "property" - ], - "eol-last": 2, - "eqeqeq": [ - 2, - "allow-null" - ], - "generator-star-spacing": [ - 2, - { - "before": true, - "after": true - } - ], - "handle-callback-err": [ - 2, - "^(err|error)$" - ], - "indent": [ - 2, - 2, - { - "SwitchCase": 1 - } - ], - "key-spacing": [ - 2, - { - "beforeColon": false, - "afterColon": true - } - ], - "new-cap": [ - 2, - { - "newIsCap": true, - "capIsNew": false - } - ], - "new-parens": 2, - "no-array-constructor": 2, - "no-caller": 2, - "no-class-assign": 2, - "no-cond-assign": 2, - "no-const-assign": 2, - "no-control-regex": 2, - "no-debugger": 2, - "no-delete-var": 2, - "no-dupe-args": 2, - "no-dupe-class-members": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-empty-character-class": 2, - "no-empty-label": 2, - "no-eval": 2, - "no-ex-assign": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": [ - 2, - "functions" - ], - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-func-assign": 2, - "no-implied-eval": 2, - "no-inner-declarations": [ - 2, - "functions" - ], - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-iterator": 2, - "no-label-var": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": [ - 2, - { - "max": 1 - } - ], - "no-native-reassign": 2, - "no-negated-in-lhs": 2, - "no-new": 2, - "no-new-func": 2, - "no-new-object": 2, - "no-new-require": 2, - "no-new-wrappers": 2, - "no-obj-calls": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-proto": 0, - "no-redeclare": 2, - "no-regex-spaces": 2, - "no-return-assign": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-shadow-restricted-names": 2, - "no-spaced-func": 2, - "no-sparse-arrays": 2, - "no-this-before-super": 2, - "no-throw-literal": 2, - "no-trailing-spaces": 0, - "no-undef": 2, - "no-undef-init": 2, - "no-unexpected-multiline": 2, - "no-unneeded-ternary": [ - 2, - { - "defaultAssignment": false - } - ], - "no-unreachable": 2, - "no-unused-vars": [ - 2, - { - "vars": "all", - "args": "none" - } - ], - "no-useless-call": 0, - "no-with": 2, - "one-var": [ - 0, - { - "initialized": "never" - } - ], - "operator-linebreak": [ - 0, - "after", - { - "overrides": { - "?": "before", - ":": "before" - } - } - ], - "padded-blocks": [ - 0, - "never" - ], - "quotes": [ - 2, - "single", - "avoid-escape" - ], - "radix": 2, - "semi": [ - 2, - "always" - ], - "semi-spacing": [ - 2, - { - "before": false, - "after": true - } - ], - "space-after-keywords": [ - 2, - "always" - ], - "space-before-blocks": [ - 2, - "always" - ], - "space-before-function-paren": [ - 2, - "never" - ], - "space-before-keywords": [ - 2, - "always" - ], - "space-in-parens": [ - 2, - "never" - ], - "space-infix-ops": 2, - "space-return-throw-case": 2, - "space-unary-ops": [ - 2, - { - "words": true, - "nonwords": false - } - ], - "spaced-comment": [ - 0, - "always", - { - "markers": [ - "global", - "globals", - "eslint", - "eslint-disable", - "*package", - "!", - "," - ] - } - ], - "use-isnan": 2, - "valid-typeof": 2, - "wrap-iife": [ - 2, - "any" - ], - "yoda": [ - 2, - "never" - ] - } -} diff --git a/vendors/update/.gitattributes b/vendors/update/.gitattributes deleted file mode 100644 index 660957e7..00000000 --- a/vendors/update/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -# Enforce Unix newlines -* text eol=lf - -# binaries -*.ai binary -*.psd binary -*.jpg binary -*.gif binary -*.png binary -*.jpeg binary diff --git a/vendors/update/.gitignore b/vendors/update/.gitignore deleted file mode 100644 index 80a228ca..00000000 --- a/vendors/update/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.DS_Store -*.sublime-* -_gh_pages -bower_components -node_modules -npm-debug.log -actual -test/actual -temp -tmp -TODO.md -vendor -.idea -benchmark -coverage diff --git a/vendors/update/.travis.yml b/vendors/update/.travis.yml deleted file mode 100644 index 09768f0d..00000000 --- a/vendors/update/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -sudo: false -language: node_js -node_js: - - "stable" - - "5" - - "4" - - "0.12" - - "0.10" -matrix: - fast_finish: true - allow_failures: - - node_js: "0.10" diff --git a/vendors/update/.verb.md b/vendors/update/.verb.md deleted file mode 100644 index fad0eb2a..00000000 --- a/vendors/update/.verb.md +++ /dev/null @@ -1,147 +0,0 @@ -# {%= name %} {%= badge("fury") %} {%= badge("travis") %} - -> {%= description %} - -## CLI - -### Install - -{%= include("install-global") %} - - -### Commands - -```sh -$ update [options] -``` - -**List updaters** - -Choose from a list of updaters and tasks to run: - -```sh -$ update list -``` - -**Run a specific updater** - -The following would run updater `foo`: - -```sh -$ update foo - -# run updater "foo" with options -$ update foo --bar=baz -``` - - -### tasks - -_(TODO)_ - -### plugins - -_(TODO)_ - -#### pipeline plugins - -_(TODO)_ - -#### instance plugins - -_(TODO)_ - -### middleware - -A middleware is a function that exposes the following parameters: - -- `file`: **{Object}** [vinyl][] file object -- `next`: **{Function}** must be called to continue on to the next file. - -```js -function rename(file, next) { - file.path = 'foo/' + file.path; - next(); -} - -// example usage: prefix all `.js` file paths with `foo/` -app.onLoad(/\.js/, rename); -``` - -The `onStream` method is a custom [middleware](docs/middleware.md) handler that the `update` - -```js -app.onStream(/lib\//, rename); -``` - - -## API - -### Install - -{%= include("install-npm", {save: true}) %} - -```js -var update = require('{%= name %}'); -``` - -## API -{%= apidocs("index.js") %} - -## Related projects -{%= related(verb.related.list) %} - -## Authoring - -### Updaters - -_(TODO)_ - -#### Tasks - -_(TODO)_ - -#### Middleware - -_(TODO)_ - -#### Plugins - -> Updater plugins follow the same signature as gulp plugins - -**Example** - -```js -function myPlugin(options) { - return through.obj(function(file, enc, next) { - var str = file.contents.toString(); - // do stuff to `file` - file.contents = new Buffer(file.contents); - next(null, file); - }); -} -``` - -### Publish - -1. Name your project following the convention: `updater-*` -2. Don't use dots in the name (e.g `.js`) -3. Make sure you add `updater` to the keywords in `package.json` -4. Tweet about your updater! - -## Running tests -{%= include("tests") %} - -## Contributing -{%= include("contributing") %} - -## Author -{%= include("author") %} - -## License -{%= copyright() %} -{%= license %} - -*** - -{%= include("footer") %} diff --git a/vendors/update/LICENSE b/vendors/update/LICENSE deleted file mode 100644 index 1e49edf8..00000000 --- a/vendors/update/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-2016, Jon Schlinkert. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendors/update/README.md b/vendors/update/README.md deleted file mode 100644 index 9718a4c3..00000000 --- a/vendors/update/README.md +++ /dev/null @@ -1,185 +0,0 @@ -# update [![NPM version](https://img.shields.io/npm/v/update.svg)](https://www.npmjs.com/package/update) [![Build Status](https://img.shields.io/travis/update/update.svg)](https://travis-ci.org/update/update) - -> Easily keep anything in your project up-to-date by installing the updaters you want to use and running `update` in the command line! Update the copyright date, licence type, ensure that a project uses your latest eslint or jshint configuration, remove deprecated package.json fields, or anything you can think of! - -## CLI - -### Install - -Install globally with [npm](https://www.npmjs.com/) - -```sh -$ npm i -g update -``` - -### Commands - -```sh -$ update [options] -``` - -**List updaters** - -Choose from a list of updaters and tasks to run: - -```sh -$ update list -``` - -**Run a specific updater** - -The following would run updater `foo`: - -```sh -$ update foo - -# run updater "foo" with options -$ update foo --bar=baz -``` - -### tasks - -_(TODO)_ - -### plugins - -_(TODO)_ - -#### pipeline plugins - -_(TODO)_ - -#### instance plugins - -_(TODO)_ - -### middleware - -A middleware is a function that exposes the following parameters: - -* `file`: **{Object}** [vinyl](http://github.com/gulpjs/vinyl) file object -* `next`: **{Function}** must be called to continue on to the next file. - -```js -function rename(file, next) { - file.path = 'foo/' + file.path; - next(); -} - -// example usage: prefix all `.js` file paths with `foo/` -app.onLoad(/\.js/, rename); -``` - -The `onStream` method is a custom [middleware](docs/middleware.md) handler that the `update` - -```js -app.onStream(/lib\//, rename); -``` - -## API - -### Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm i update --save -``` - -```js -var update = require('update'); -``` - -## API - -### [Update](index.js#L30) - -Create an `update` application. This is the main function exported by the update module. - -**Params** - -* `options` **{Object}** - -**Example** - -```js -var Update = require('update'); -var update = new Update(); -``` - -## Related projects - -* [assemble](https://www.npmjs.com/package/assemble): Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… [more](https://www.npmjs.com/package/assemble) | [homepage](https://github.com/assemble/assemble) -* [boilerplate](https://www.npmjs.com/package/boilerplate): Tools and conventions for authoring and publishing boilerplates that can be generated by any build… [more](https://www.npmjs.com/package/boilerplate) | [homepage](http://boilerplates.io) -* [composer](https://www.npmjs.com/package/composer): API-first task runner with three methods: task, run and watch. | [homepage](https://github.com/jonschlinkert/composer) -* [generate](https://www.npmjs.com/package/generate): Fast, composable, highly extendable project generator with a user-friendly and expressive API. | [homepage](https://github.com/generate/generate) -* [scaffold](https://www.npmjs.com/package/scaffold): Conventions and API for creating declarative configuration objects for project scaffolds - similar in format… [more](https://www.npmjs.com/package/scaffold) | [homepage](https://github.com/jonschlinkert/scaffold) -* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine.… [more](https://www.npmjs.com/package/templates) | [homepage](https://github.com/jonschlinkert/templates) -* [update](https://www.npmjs.com/package/update): Update | [homepage](https://github.com/jonschlinkert/update) -* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb) - -## Authoring - -### Updaters - -_(TODO)_ - -#### Tasks - -_(TODO)_ - -#### Middleware - -_(TODO)_ - -#### Plugins - -> Updater plugins follow the same signature as gulp plugins - -**Example** - -```js -function myPlugin(options) { - return through.obj(function(file, enc, next) { - var str = file.contents.toString(); - // do stuff to `file` - file.contents = new Buffer(file.contents); - next(null, file); - }); -} -``` - -### Publish - -1. Name your project following the convention: `updater-*` -2. Don't use dots in the name (e.g `.js`) -3. Make sure you add `updater` to the keywords in `package.json` -4. Tweet about your updater! - -## Running tests - -Install dev dependencies: - -```sh -$ npm i -d && npm test -``` - -## Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/update/issues/new). - -## Author - -**Jon Schlinkert** - -* [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) - -## License - -Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert) -Released under the MIT license. - -*** - -_This file was generated by [verb](https://github.com/verbose/verb) on January 09, 2016._ \ No newline at end of file diff --git a/vendors/update/bin/update.js b/vendors/update/bin/update.js deleted file mode 100755 index 21608671..00000000 --- a/vendors/update/bin/update.js +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node - -var path = require('path'); -var gm = require('global-modules'); -var Runner = require('../lib/runner/runner')(); -var utils = require('../lib/utils'); -var argv = require('minimist')(process.argv.slice(2), { - alias: {verbose: 'v'} -}); - -var cmd = utils.commands(argv); -var runner = new Runner(argv); - -runner.base.option(argv); -runner.option(argv); - -var task = cmd.list ? ['list', 'default'] : ['default']; - -runner.on('*', function(method, key, val) { - console.log(method + ':', key, val); -}); - -if (argv.verbose) { - runner.on('register', function(key) { - utils.ok(utils.gray('registered'), 'updater', utils.cyan(key)); - }); -} - -runner.registerEach('update-*', {cwd: gm}); - -runner.base.task('run', function(cb) { - runner.run(cb); -}); - -runner.base.build(task, function(err) { - if (err) return console.error(err); - utils.timestamp('finished ' + utils.green(utils.successSymbol)); -}); diff --git a/vendors/update/gulpfile.js b/vendors/update/gulpfile.js deleted file mode 100644 index 7d0c54ab..00000000 --- a/vendors/update/gulpfile.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); -var mocha = require('gulp-mocha'); -var istanbul = require('gulp-istanbul'); -var eslint = require('gulp-eslint'); - -var lint = ['index.js', 'lib/*.js', 'test/*.js']; - -gulp.task('coverage', function () { - return gulp.src(lint) - .pipe(istanbul()) - .pipe(istanbul.hookRequire()); -}); - -gulp.task('mocha', ['coverage'], function () { - return gulp.src('test/*.js') - .pipe(mocha({reporter: 'spec'})) - .pipe(istanbul.writeReports()); -}); - -gulp.task('eslint', function () { - return gulp.src(lint) - .pipe(eslint()) -}); - -gulp.task('default', ['mocha', 'eslint']); diff --git a/vendors/update/index.js b/vendors/update/index.js deleted file mode 100644 index 1b941e01..00000000 --- a/vendors/update/index.js +++ /dev/null @@ -1,169 +0,0 @@ -/*! - * update - * - * Copyright (c) 2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - -'use strict'; - -var path = require('path'); -var Base = require('assemble-core'); -var expand = require('expand-args'); -var minimist = require('minimist'); -var config = require('./lib/config'); -var locals = require('./lib/locals'); -var utils = require('./lib/utils'); - -/** - * Create an `update` application. This is the main function exported - * by the update module. - * - * ```js - * var Update = require('update'); - * var update = new Update(); - * ``` - * @param {Object} `options` - * @api public - */ - -function Update(options) { - if (!(this instanceof Update)) { - return new Update(options); - } - Base.call(this, options); - this.name = this.options.name || 'update'; - this.isUpdate = true; - this.initUpdate(this); -} - -/** - * Inherit assemble-core - */ - -Base.extend(Update); - -/** - * Initialize Updater defaults - */ - -Update.prototype.initUpdate = function(base) { - this.set('updaters', {}); - - // custom middleware handlers - this.handler('onStream'); - this.handler('preWrite'); - this.handler('postWrite'); - - // parse command line arguments - var argv = expand(minimist(process.argv.slice(2)), { - alias: {v: 'verbose'} - }); - - this.option('argv', argv); - - // expose `argv` on the instance - this.mixin('argv', function(prop) { - var args = [].slice.call(arguments); - args.unshift(argv); - return utils.get.apply(null, args); - }); - - // load the package.json for the updater - this.data(utils.pkg.sync(this.options.path)); - config(this); - - this.use(locals('update')) - .use(utils.runtimes({ - displayName: function(key) { - return base.name === key ? key : (base.name + ':' + key); - } - })) - .use(utils.store()) - .use(utils.pipeline()) - .use(utils.loader()) - .use(utils.cli()) - .use(utils.defaults()) - .use(utils.opts()) - - var data = utils.get(this.cache.data, 'update'); - this.config.process(utils.extend({}, data, argv)); - - this.engine(['md', 'tmpl'], require('engine-base')); - this.onLoad(/\.(md|tmpl)$/, function(view, next) { - utils.matter.parse(view, next); - }); -}; - -/** - * Returns a function for resolving filepaths from the given `directory` - * or from the user's current working directory if no directory - * is passed. - * - * ```js - * var cwd = update.cwd('foo'); - * var a = cwd('bar'); - * var b = cwd('baz'); - * ``` - * @param {String} `dir` - * @return {Function} - */ - -Update.prototype.cwd = function(dir) { - var cwd = dir || process.cwd(); - return function() { - var args = [].slice.call(arguments); - args.unshift(cwd); - return path.resolve.apply(null, args); - }; -}; - -/** - * Temporary logger method. - * TODO: add event logger - */ - -Update.prototype.log = function() { - this.emit.bind(this, 'log').apply(this, arguments); - if (this.enabled('verbose')) { - console.log.apply(console, arguments); - } -}; - -/** - * Register updater `name` with the given `update` - * instance. - * - * @param {String} `name` - * @param {Object} `update` Instance of update - * @return {Object} Returns the instance for chaining - */ - -Update.prototype.updater = function(name, app) { - if (arguments.length === 1 && typeof name === 'string') { - return this.updaters[name]; - } - - app.use(utils.runtimes({ - displayName: function(key) { - return app.name === key ? key : (app.name + ':' + key); - } - })); - - this.emit('updater', name, app); - this.updaters[name] = app; - return app; -}; - -/** - * Expose `Update` - */ - -module.exports = Update; - -/** - * Expose `utils` and package.json metadata - */ - -module.exports.utils = utils; -module.exports.pkg = require('./package'); diff --git a/vendors/update/lib/config.js b/vendors/update/lib/config.js deleted file mode 100644 index c829c9ba..00000000 --- a/vendors/update/lib/config.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - - -module.exports = function(app) { - if (!app.isUpdate) return; - - var config = require('base-config'); - app.use(config()); - - app.config - .map('addViews') - .map('addView') - .map('helpers') - .map('asyncHelpers') - .map('plugins', function(val) { - app.visit('plugin', val); - }) - .map('data', function(val) { - app.visit('data', val); - }) - .map('collections', function(val) { - app.visit('create', val); - }) - .map('reflinks', function(val) { - app.data({reflinks: val}); - }) - .map('related', function(val) { - app.data({related: val}); - }); -}; diff --git a/vendors/update/lib/locals.js b/vendors/update/lib/locals.js deleted file mode 100644 index 4d0097bd..00000000 --- a/vendors/update/lib/locals.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -var get = require('get-value'); -var set = require('set-value'); -var utils = require('./utils'); - -module.exports = function(name) { - name = name || utils.project(process.cwd()); - - return function(app) { - app.define('locals', new Locals(name, this)); - }; -}; - -function Locals(name, app) { - this.cache = get(app, ['cache.data', name]) || {}; -} - -Locals.prototype.get = function(key) { - return get(this.cache, key); -}; - -Locals.prototype.set = function(key, value) { - set(this.cache, key, value); - return this; -}; diff --git a/vendors/update/lib/middleware/index.js b/vendors/update/lib/middleware/index.js deleted file mode 100644 index 23b2930d..00000000 --- a/vendors/update/lib/middleware/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('export-files')(__dirname); diff --git a/vendors/update/lib/middleware/json.js b/vendors/update/lib/middleware/json.js deleted file mode 100644 index b7cbd14b..00000000 --- a/vendors/update/lib/middleware/json.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var sortArrays = require('sort-object-arrays'); - -module.exports = function(app, base, env) { - base.onLoad(/(\.eslintrc|\.js(on|hintrc))$/, function(file, next) { - file.json = JSON.parse(file.content); - next(); - }); - - base.preWrite(/\.js(on|hintrc)$/, function(file, next) { - if (typeof file.json === 'undefined') { - next(new Error('json middleware expects `file.json` to be an object')); - return; - } - - file.json = sortArrays(file.json); - file.content = JSON.stringify(file.json, null, 2); - file.content += '\n'; - next(); - }); -}; diff --git a/vendors/update/lib/runner/argv.js b/vendors/update/lib/runner/argv.js deleted file mode 100644 index 95dd7508..00000000 --- a/vendors/update/lib/runner/argv.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -var utils = require('../utils'); - -module.exports = function(options) { - return function(app) { - - this.define('argv', function(argv, commands, fn) { - var args = {}; - args.argv = argv; - args.commands = []; - args.updaters = {}; - - args.flags = utils.expandArgs(utils.omit(argv, ['_', 'files'])); - args.flagskeys = Object.keys(args.flags); - - var files = argv.files ? utils.pick(argv, 'files') : null; - if (files) args.flags.files = files; - - var arr = argv._; - var len = arr.length, i = -1; - - while (++i < len) { - var key = arr[i]; - - if (/\W/.test(key)) { - var obj = utils.expand(key); - - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - var val = obj[prop]; - utils.union(args, 'updaters.' + prop, val); - } - } - continue; - } - - if (utils.contains(commands, key)) { - args.commands.push(key); - continue; - } - // fn(key, args); - var updaters = this.base.updaters; - if (key in updaters) { - utils.union(args, 'updaters.' + key, 'default'); - - } else if (key !== 'base') { - utils.union(args, 'updaters.base', key); - } - } - return args; - }); - }; -}; - diff --git a/vendors/update/lib/runner/decorate.js b/vendors/update/lib/runner/decorate.js deleted file mode 100644 index e62a2f49..00000000 --- a/vendors/update/lib/runner/decorate.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var path = require('path'); -var utils = require('../utils'); - -module.exports = function(options) { - return function(app) { - - this.define('decorate', function(name, app, options) { - app.option('name', name) - .option('fullname', options.fullname || name) - .option('path', options.path || ''); - - app.create('templates', { - cwd: path.resolve(options.path, 'templates'), - renameKey: function(key) { - return path.basename(key); - } - }); - - var base = this.base; - - app.define('getFile', function(name) { - var view = base.files.getView.apply(base.files, arguments); - if (!view) { - view = app.templates.getView.apply(app.templates, arguments); - } - if (!view) return null; - view.basename = view.basename.replace(/^_/, '.'); - view.basename = view.basename.replace(/^$/, ''); - return view; - }); - - base.define('getFile', app.getFile); - base.files.getFile = base.files.getView.bind(base.files); - return this; - }); - }; -}; diff --git a/vendors/update/lib/runner/env.js b/vendors/update/lib/runner/env.js deleted file mode 100644 index 4d431b76..00000000 --- a/vendors/update/lib/runner/env.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -var path = require('path'); -var define = require('define-property'); -var extend = require('extend-shallow'); -var get = require('get-value'); -var set = require('set-value'); - -function Env(options) { - this.options = options || {}; - define(this, 'cache', {}); -} - -Env.prototype.set = function(key, value) { - set(this, key, value); - return this; -}; - -Env.prototype.get = function(key) { - return get(this, key); -}; - -Object.defineProperty(Env.prototype, 'cwd', { - set: function(dir) { - this.cache.cwd = dir; - }, - get: function() { - return this.cache.cwd || process.cwd(); - } -}); - -Object.defineProperty(Env.prototype, 'pkg', { - set: function() { - throw new Error('env.pkg is a getter and cannot be set directly.'); - }, - get: function() { - if (!this.cache.pkg) { - this.cache.pkg = require(path.resolve(this.cwd, 'package.json')); - } - return this.cache.pkg; - } -}); - -/** - * Expose `Env` - */ - -module.exports = function(options) { - return function(app) { - var opts = extend({}, this.options, options); - app.define('env', new Env(opts)); - }; -}; diff --git a/vendors/update/lib/runner/list.js b/vendors/update/lib/runner/list.js deleted file mode 100644 index 15122eed..00000000 --- a/vendors/update/lib/runner/list.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var utils = require('../utils'); - -module.exports = function(options) { - return function(app) { - - this.define('list', function(cb) { - var questions = utils.questions(this.base.options); - var choices = utils.list(this.base.updaters); - if (!choices.length) { - console.log(utils.cyan(' No updater tasks found.')); - return cb(null, { - updaters: {} - }); - } - - var question = { - updaters: { - message: 'pick an updater to run', - type: 'checkbox', - choices: choices - } - }; - - questions.ask(question, function(err, answers) { - if (err) return cb(err); - var args = { - updaters: {} - }; - answers.updaters.forEach(function(answer) { - var segs = answer.split(':'); - if (segs.length === 1) return; - utils.union(args.updaters, segs[0], (segs[1] || 'default').split(',')); - }); - return cb(null, args); - }); - }); - }; -}; diff --git a/vendors/update/lib/runner/listen.js b/vendors/update/lib/runner/listen.js deleted file mode 100644 index dc48f2bb..00000000 --- a/vendors/update/lib/runner/listen.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = function(options) { - return function(app) { - this.define('_listen', function() { - if (this.base.disabled('verbose')) return; - var store = ['store.set', 'store.has', 'store.get', 'store.del']; - var methods = ['set', 'has', 'get', 'del', 'option', 'data']; - - var names = store.concat(methods); - var len = names.length, i = -1; - var multi = this; - - while (++i < len) { - var method = names[i]; - var prop = method.split('.'); - - if (prop.length === 2) { - this.base[prop[0]].on(prop[1], multi.emit.bind(multi, method)); - this.base[prop[0]].on(prop[1], multi.emit.bind(multi, '*', method)); - } else { - this.base.on(method, function(key, val) { - multi.emit(method, key, val); - multi.emit('*', method, key, val); - }); - } - } - }); - }; -}; diff --git a/vendors/update/lib/runner/run.js b/vendors/update/lib/runner/run.js deleted file mode 100644 index 864451bb..00000000 --- a/vendors/update/lib/runner/run.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -var utils = require('../utils'); - -module.exports = function(options) { - return function(app) { - - this.define('getApp', function(name) { - return name !== 'base' - ? this.base.updater(name) - : this.base; - }); - - this.define('run', function(args, cb) { - if (typeof args === 'function') { - cb = args; - args = null; - } - - if (!args) { - var commands = this.options.commands || this.commands; - args = this.argv(this.base.get('argv'), commands); - } - - if (args.commands && args.commands.length > 1) { - var cmd = '"' + args.commands.join(', ') + '"'; - return cb(new Error('Error: only one root level command may be given: ' + cmd)); - } - - this.base.cli.process(args.flags); - var self = this; - - utils.async.eachOf(args.updaters, function(tasks, name, next) { - var app = self.getApp(name); - - tasks = tasks.filter(Boolean); - if (!tasks.length) return next(); - - self.emit('task', name, tasks); - app.build(tasks, next); - }, cb); - - return this; - }); - }; -}; diff --git a/vendors/update/lib/runner/runner.js b/vendors/update/lib/runner/runner.js deleted file mode 100644 index 7d458e72..00000000 --- a/vendors/update/lib/runner/runner.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -var path = require('path'); -var Base = require('base'); -var option = require('base-options'); -var store = require('base-store'); -var fns = require('../middleware'); -var Updater = require('./updater'); -var tasks = require('../tasks'); -var utils = require('../utils'); -var decorate = require('./decorate'); -var listen = require('./listen'); -var args = require('./argv'); -var list = require('./list'); -var run = require('./run'); -var Update = require('../..'); - -module.exports = function(namespace, config) { - function Runner(argv, options) { - if (!(this instanceof Runner)) { - return new Runner(argv, options); - } - - Base.call(this); - this.use(option()); - this.use(store()); - this.use(decorate()); - this.use(listen()); - this.use(args()); - this.use(list()); - this.use(run()); - - this.options = options || {}; - this.commands = ['set', 'get', 'del', 'store', 'init', 'option', 'data', 'list']; - - this.base = new Update() - .on('error', console.error) - .set('argv', argv) - - // register middleware - for (var fn in fns) { - fns[fn](this.base, this.base, this); - } - - // register tasks - for (var key in tasks) { - this.base.task(key, tasks[key](this.base, this.base, this)); - } - - this._listen(); - } - - Base.extend(Runner); - - Runner.prototype.updater = function(name) { - return this.base.updater(name); - }; - - Runner.prototype.build = function() { - this.base.build.apply(this.base, arguments); - return this; - }; - - Runner.prototype.register = function(name, options, updater) { - if (arguments.length === 2) { - updater = options; - options = {}; - } - - var Ctor = options.Update || Update; - var app = new Ctor(this.base.options); - this.decorate(name, app, options); - - updater.call(app, app, this.base, this); - this.base.updater(name, app); - - this.emit('register', name, app); - return this; - }; - - Runner.prototype.registerEach = function(patterns, options) { - utils.matchFiles(patterns, options).forEach(function(fp) { - var filepath = path.resolve(fp, 'updatefile.js'); - var updater = require(filepath); - - // get the full project name ('updater-foo') - var fullname = utils.project(fp); - // get the updater name ('foo') - var name = utils.renameFn(fullname, options); - var opts = {}; - - // get the constructor to use (node_modules or our 'Update') - opts.Update = utils.resolveModule(fp); - opts.fullname = fullname; - opts.path = fp; - - this.register(name, opts, updater); - }.bind(this)); - return this; - }; - - /** - * Expose `Runner` - */ - - return Runner; -}; diff --git a/vendors/update/lib/runner/updater.js b/vendors/update/lib/runner/updater.js deleted file mode 100644 index 222dcfac..00000000 --- a/vendors/update/lib/runner/updater.js +++ /dev/null @@ -1,127 +0,0 @@ -'use strict'; - -var path = require('path'); -var set = require('set-value'); -var define = require('define-property'); -var use = require('use'); - -/** - * Create an instance of `Updater`, optionally passing - * a default object to initialize with. - * - * ```js - * var app = new Updater({ - * path: 'foo.html' - * }); - * ``` - * @param {Object} `app` - * @api public - */ - -function Updater(name, config, fn) { - if (!(this instanceof Updater)) { - return new Updater(config); - } - - if (typeof config === 'function') { - fn = config; - config = {}; - } - - this.isUpdater = true; - define(this, 'cache', {}); - config = config || {}; - config.fn = fn; - - for (var key in config) { - if (!(key in this)) { - this.set(key, config[key]); - } - } - use(this); -} - -/** - * Set `key` on the instance with the given `value`. - * - * @param {String} `key` - * @param {Object} `value` - * @return {Object} Returns the instance for chaining - */ - -Updater.prototype.set = function(key, value) { - set(this, key, value); - return this; -}; - -/** - * Custom `inspect` method. - */ - -// Updater.prototype.inspect = function() { -// var name = this.name || 'Updater'; -// var inspect = []; - -// if (this.alias) { -// inspect.push('"' + this.alias + '"'); -// } -// return '<' + name + ' ' + inspect.join(' ') + '>'; -// }; - -/** - * Get the `cwd` (current working directory) for the updater. - */ - -define(Updater.prototype, 'cwd', { - set: function(dir) { - this.cache.cwd = dir; - }, - get: function() { - return this.cache.cwd || (this.cache.cwd = process.cwd()); - } -}); - -/** - * Get the `dirname` for the updater. - */ - -define(Updater.prototype, 'dirname', { - set: function(dir) { - this.path = path.join(dir, path.basename(this.path)); - }, - get: function() { - return path.dirname(this.path); - } -}); - -/** - * Get the `basename` for the updater. - */ - -define(Updater.prototype, 'basename', { - set: function(basename) { - this.path = path.join(path.dirname(this.path), basename); - }, - get: function() { - return path.basename(this.path); - } -}); - -/** - * Get the `filename` for the updater. - */ - -define(Updater.prototype, 'filename', { - set: function(filename) { - this.path = path.join(path.dirname(this.path), filename + this.extname); - }, - get: function() { - return path.basename(this.path, this.extname); - } -}); - -/** - * Expose `Updater` - */ - -module.exports = Updater; diff --git a/vendors/update/lib/tasks/default.js b/vendors/update/lib/tasks/default.js deleted file mode 100644 index 54bcf12f..00000000 --- a/vendors/update/lib/tasks/default.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function(app, base, env) { - return ['del', 'files', 'run', 'dest']; -}; diff --git a/vendors/update/lib/tasks/del.js b/vendors/update/lib/tasks/del.js deleted file mode 100644 index 98b46cdf..00000000 --- a/vendors/update/lib/tasks/del.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var path = require('path'); -var async = require('async'); -var rimraf = require('rimraf'); - -var list = ['.npmignore', '.jshintrc', '.eslintrc']; - -module.exports = function(app, base, env) { - var files = base.option('delete') || list; - - return function(cb) { - async.each(files, function(fp, next) { - rimraf(path.resolve(process.cwd(), fp), next); - }, cb); - }; -}; diff --git a/vendors/update/lib/tasks/dest.js b/vendors/update/lib/tasks/dest.js deleted file mode 100644 index dc354e09..00000000 --- a/vendors/update/lib/tasks/dest.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var utils = require('../utils'); - -module.exports = function(app, base, env) { - var plugins = base.get('argv.plugins'); - - function handle(stage) { - return utils.through.obj(function(file, enc, next) { - if (file.isNull()) return next(); - app.handle(stage, file, next); - }); - } - - return function(cb) { - app.toStream('files') - .on('error', cb) - .pipe(handle('onStream')) - .on('error', cb) - .pipe(app.pipeline(plugins)) - .on('error', cb) - .pipe(handle('preWrite')) - .on('error', cb) - .pipe(app.dest('.')) - .pipe(utils.exhaust(handle('postWrite'))) - .on('error', cb) - .on('end', cb); - }; -}; diff --git a/vendors/update/lib/tasks/files.js b/vendors/update/lib/tasks/files.js deleted file mode 100644 index 4c958ac5..00000000 --- a/vendors/update/lib/tasks/files.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var path = require('path'); - -module.exports = function(app, base, env) { - base.create('files', { - renameKey: function(key) { - return path.basename(key); - } - }); - - var glob = base.get('argv.files'); - if (glob) { - glob = glob.split(','); - } else { - glob = ['*', 'lib/*', 'bin/*']; - } - - return function(cb) { - base.files(glob, {dot: true, ignore: ['.DS_Store']}); - base.emit('loaded', base.files); - cb(); - } -}; diff --git a/vendors/update/lib/tasks/index.js b/vendors/update/lib/tasks/index.js deleted file mode 100644 index 23b2930d..00000000 --- a/vendors/update/lib/tasks/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('export-files')(__dirname); diff --git a/vendors/update/lib/tasks/lint.js b/vendors/update/lib/tasks/lint.js deleted file mode 100644 index 3c4fe17f..00000000 --- a/vendors/update/lib/tasks/lint.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var through = require('through2'); -var eslint = require('gulp-eslint'); - -module.exports = function(app, base, env) { - return function() { - return base.toStream('files') - .pipe(through.obj(function(file, enc, cb) { - if (/\.js$/.test(file.path)) { - this.push(file); - } - cb(); - })) - .pipe(eslint()) - .pipe(eslint.format()) - }; -}; diff --git a/vendors/update/lib/tasks/list.js b/vendors/update/lib/tasks/list.js deleted file mode 100644 index 92ffe1d4..00000000 --- a/vendors/update/lib/tasks/list.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function(app, base, env) { - return function(cb) { - env.list(function(err, args) { - if (err) return cb(err); - env.run(args, cb); - }); - }; -}; diff --git a/vendors/update/lib/tasks/noop.js b/vendors/update/lib/tasks/noop.js deleted file mode 100644 index 0386d7e0..00000000 --- a/vendors/update/lib/tasks/noop.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function(app, base, env) { - return function(cb) { - return cb(); - }; -}; diff --git a/vendors/update/lib/tasks/rename.js b/vendors/update/lib/tasks/rename.js deleted file mode 100644 index ad419c16..00000000 --- a/vendors/update/lib/tasks/rename.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -var path = require('path'); -var rimraf = require('rimraf'); -var through = require('through2'); - -var mapping = { - 'LICENSE': 'LICENSE-MIT', - 'readme.md': 'README.md' -}; - -module.exports = function(app, base, env) { - var config = base.option('rename') || mapping; - - app.task('undo', function() { - return base.toStream('files') - .pipe(rename(config, {invert: true})); - }); - - return function() { - return base.toStream('files') - .pipe(rename(config)); - }; -}; - -function rename(mapping, options) { - options = options || {}; - if (options.invert === true) { - mapping = invert(mapping); - } - return through.obj(function(file, enc, next) { - if (file.isNull()) return next(null, file); - var fp = file.path; - function del(err) { - if (err) return next(err); - next(null, file); - } - for (var key in mapping) { - if (isMatch(file, mapping[key])) { - file.path = path.resolve(file.base, key); - rimraf(fp, del); - return; - } - } - next(null, file); - }); -} - -function isMatch(file, src) { - file.basename = path.basename(file.path); - if (src instanceof RegExp) { - return src.test(file.basename) || src.test(file.path); - } - if (typeof src === 'string') { - return src === file.path || src === file.basename; - } -} - -function invert(obj) { - var res = {}; - for (var key in obj) { - res[obj[key]] = key; - } - return res; -} diff --git a/vendors/update/lib/tasks/tree.js b/vendors/update/lib/tasks/tree.js deleted file mode 100644 index 06e6cc80..00000000 --- a/vendors/update/lib/tasks/tree.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var utils = require('../utils'); - -module.exports = function(app, base, env) { - return function(cb) { - console.log(utils.tree(base.updaters)); - cb(); - }; -}; diff --git a/vendors/update/lib/utils.js b/vendors/update/lib/utils.js deleted file mode 100644 index 122ee60e..00000000 --- a/vendors/update/lib/utils.js +++ /dev/null @@ -1,329 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var path = require('path'); -var pkg = require(path.resolve(__dirname, '../package')); - -/** - * Module dependencies - */ - -var utils = require('lazy-cache')(require); -var fn = require; -require = utils; - -require('assemble-loader', 'loader'); -require('async'); -require('base-cli', 'cli'); -require('base-pipeline', 'pipeline'); -require('base-store', 'store'); -require('composer-runtimes', 'runtimes'); -require('expand-args'); -require('expand-object', 'expand'); -require('extend-shallow', 'extend'); -require('for-own'); -require('get-value', 'get'); -require('load-pkg', 'pkg'); -require('matched', 'glob'); -require('micromatch', 'mm'); -require('object.omit', 'omit'); -require('object.pick', 'pick'); -require('parser-front-matter', 'matter'); -require('project-name', 'project'); -require('question-cache', 'questions'); -require('set-value', 'set'); -require('stream-exhaust', 'exhaust'); -require('through2', 'through'); -require('union-value', 'union'); - -require('success-symbol'); -require('ansi-yellow', 'yellow'); -require('ansi-green', 'green'); -require('ansi-gray', 'gray'); -require('ansi-cyan', 'cyan'); -require('ansi-red', 'red'); -require('time-stamp', 'stamp'); -require = fn; - -/** - * Logging utils - */ - -utils.timestamp = function(msg) { - var time = '[' + utils.gray(utils.stamp('HH:mm:ss', new Date())) + ']'; - return console.log(time, msg); -}; - -function Status(status) { - status = status || {}; - this.err = status.err || null; - this.code = status.code || null; - this.name = status.name || ''; - this.msg = status.msg || ''; -} - -utils.ok = function() { - var args = utils.toArray(arguments) || []; - args.unshift(' ' + utils.green(utils.successSymbol)); - console.log.apply(console, args); -}; -utils.success = function() { - var args = utils.toArray(arguments) || []; - args[0] = utils.green(args[0] || ''); - console.log.apply(console, args); -}; -utils.error = function() { - var args = utils.toArray(arguments); - args.unshift(utils.red('Error:')); - console.error.apply(console, args); -}; - -/** - * CLI utils - */ - -utils.commands = function(argv) { - argv._ = argv._ || []; - var commands = {}; - - argv._.forEach(function(key) { - commands[key] = true; - }); - return commands; -}; - -utils.identity = function(val) { - return val; -}; - -utils.arrayify = function(val) { - return Array.isArray(val) ? val : [val]; -}; - -utils.toArgv = function(args) { - var argv = args.flags; - argv._ = args.commands; - return argv; -}; - -utils.toArray = function(val) { - if (Array.isArray(val)) return val; - if (val && val.length) { - return [].slice.call(val); - } -}; - -utils.contains = function(arr, key) { - return arr.indexOf(key) > -1; -}; - -utils.npm = function(name) { - return utils.tryRequire(name) || utils.tryRequire(path.resolve(name)); -}; - -utils.exists = function(fp) { - return fs.existsSync(fp); -}; - -/** - * Rename a filepath to the "nickname" of the project. - * - * ```js - * renameFn('updater-foo'); - * //=> 'foo' - * ``` - */ - -utils.renameFn = function(filename, options) { - if (options && typeof options.renameFn === 'function') { - return options.renameFn(filename); - } - return filename.slice(filename.indexOf('-') + 1); -}; - -/** - * Return a glob of file paths - */ - -utils.matchFiles = function(pattern, options) { - options = options || {}; - var isMatch = utils.mm.matcher(pattern); - var files = fs.readdirSync(options.cwd); - var len = files.length, i = -1; - var res = []; - while (++i < len) { - var name = files[i]; - if (name === 'update') continue; - var fp = path.join(options.cwd, name); - if (isMatch(fp) || isMatch(name)) { - res.push(fp); - } - } - return res; -}; - -/** - * Resolve the correct updater module to instantiate. - * If `update` exists in `node_modules` of the cwd, - * then that will be used to create the instance, - * otherwise this module will be used. - */ - -utils.resolveModule = function(dir) { - dir = path.join(dir, 'node_modules/', pkg.name); - if (utils.exists(dir)) { - return require(path.resolve(dir)); - } - return null; -}; - -/** - * Print a tree of "updaters" and their tasks - * - * ```js - * utils.tree(updaters); - * ``` - */ - -utils.tree = function(updaters) { - var res = ''; - for (var key in updaters) { - res += utils.cyan(key) + '\n'; - for (var task in updaters[key].tasks) { - res += ' - ' + task + '\n'; - } - } - return res; -}; - -/** - * Return a list of "updaters" and their tasks - * - * ```js - * utils.list(updaters); - * ``` - */ - -utils.list = function(updaters) { - var list = []; - for (var key in updaters) { - var updater = updaters[key]; - if (!Object.keys(updater.tasks).length) { - continue; - } - - var hasDefault = updater.tasks['default']; - var name = updater.option('name'); - var item = { - name: name + (hasDefault ? ' (default)' : ''), - value: key, - short: name + (hasDefault ? ':default' : '') - }; - list.push(item); - for (var task in updater.tasks) { - if (task === 'default') continue; - list.push({ - name: ' - ' + task, - value: key + ':' + task, - short: key + ':' + task - }); - } - } - return list; -}; - -/** - * Try to require a file - */ - -utils.tryRequire = function(name) { - try { - return require(name); - } catch (err) { - console.log(err); - } - return null; -}; - -/** - * Try to read a file - */ - -utils.tryRead = function(fp) { - try { - return fs.readFileSync(fp); - } catch (err) {} - return null; -}; - -utils.tryParse = function(str) { - try { - return JSON.parse(str); - } catch (err) {} - return {}; -}; - -utils.register = function(pattern, base, update, options) { - utils.matchFiles(pattern, options).forEach(function(fp) { - var name = utils.project(fp); - var mod = utils.resolveModule(fp) || update; - var app = mod(base.options) - .option('name', name) - .set('path', fp); - - require(utils.updatefile(fp))(app, base); - base.updater(name, app); - }); -}; - -utils.opts = function(key) { - key = key || 'opts'; - return function(app) { - var name = this.options.name || 'base'; - this.define(key, function() { - var config = this.defaults.apply(this, arguments); - return function(key, opts) { - var args = [].concat.apply([], [].slice.call(arguments)); - var prop = typeof key === 'string' ? args.shift() : null; - var val; - - if (prop && !args.length) { - val = utils.get(config, prop); - if (val) return val; - } - - var options = utils.extend.apply(utils.extend, [config].concat(args)); - return prop ? utils.get(options, prop) : options; - }; - }); - }; -}; - -utils.defaults = function(key) { - key = key || 'defaults'; - return function(app) { - this.define(key, function() { - var args = [].concat.apply([], [].slice.call(arguments)); - args.unshift({}, this.options); - return utils.extend.apply(utils.extend, args); - }); - }; -}; - -/** - * Restore `require` - */ - -require = fn; - -/** - * Expose `utils` - */ - -module.exports = utils; - -/** - * Expose utils - */ - -module.exports = utils; diff --git a/vendors/update/package.json b/vendors/update/package.json deleted file mode 100644 index c7db06ec..00000000 --- a/vendors/update/package.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "name": "update", - "description": "Easily keep anything in your project up-to-date by installing the updaters you want to use and running `update` in the command line! Update the copyright date, licence type, ensure that a project uses your latest eslint or jshint configuration, remove deprecated package.json fields, or anything you can think of!", - "version": "0.4.2", - "homepage": "https://github.com/update/update", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "authors": [ - "Brian Woodward (https://github.com/doowb)", - "Jon Schlinkert (https://github.com/jonschlinkert)" - ], - "contributors": [ - "Brian Woodward (https://github.com/doowb)", - "Jon Schlinkert (https://github.com/jonschlinkert)" - ], - "repository": "update/update", - "bugs": { - "url": "https://github.com/update/update/issues" - }, - "license": "MIT", - "files": [ - "bin", - "index.js", - "lib/" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, - "preferGlobal": true, - "bin": { - "update": "bin/update.js" - }, - "dependencies": { - "ansi-cyan": "^0.1.1", - "ansi-gray": "^0.1.1", - "ansi-green": "^0.1.1", - "ansi-red": "^0.1.1", - "ansi-yellow": "^0.1.1", - "assemble-core": "^0.8.0", - "assemble-loader": "^0.2.6", - "async": "^1.5.2", - "base": "^0.6.3", - "base-cli": "^0.4.0", - "base-config": "^0.3.3", - "base-options": "^0.5.4", - "base-pipeline": "^0.1.4", - "base-store": "^0.3.2", - "composer-runtimes": "^0.7.0", - "define-property": "^0.2.5", - "engine-base": "^0.1.2", - "expand-args": "^0.3.1", - "expand-object": "^0.4.1", - "export-files": "^2.1.0", - "extend-shallow": "^2.0.1", - "for-own": "^0.1.3", - "get-value": "^2.0.2", - "global-modules": "^0.2.0", - "gulp-eslint": "^1.1.1", - "lazy-cache": "^1.0.3", - "load-pkg": "^3.0.1", - "matched": "^0.4.1", - "micromatch": "^2.3.7", - "minimist": "^1.2.0", - "object.omit": "^2.0.0", - "object.pick": "^1.1.1", - "parser-front-matter": "^1.3.0", - "project-name": "^0.2.3", - "question-cache": "^0.3.5", - "rimraf": "^2.5.0", - "set-value": "^0.3.2", - "sort-object-arrays": "^0.1.1", - "stream-exhaust": "^1.0.1", - "success-symbol": "^0.1.0", - "through2": "^2.0.0", - "time-stamp": "^0.1.3", - "union-value": "^0.2.1", - "use": "^1.1.2" - }, - "devDependencies": { - "buffer-equal": "^1.0.0", - "consolidate": "^0.13.1", - "coveralls": "^2.11.6", - "data-store": "^0.12.1", - "engine-handlebars": "^0.8.0", - "event-stream": "^3.3.2", - "graceful-fs": "^4.1.2", - "gulp": "^3.9.0", - "gulp-format-md": "^0.1.5", - "gulp-istanbul": "^0.10.3", - "gulp-mocha": "^2.2.0", - "is-buffer": "^1.1.1", - "istanbul": "^0.4.1", - "kind-of": "^3.0.2", - "mocha": "^2.3.4", - "resolve-glob": "^0.1.8", - "should": "^8.0.2", - "sinon": "^1.17.2", - "swig": "^1.4.2", - "vinyl": "^1.1.0" - }, - "keywords": [ - "lint", - "next", - "repo", - "update" - ], - "verb": { - "related": { - "list": [ - "assemble", - "boilerplate", - "composer", - "generate", - "scaffold", - "templates", - "update", - "verb" - ], - "description": "" - }, - "reflinks": [ - "boilerplate", - "scaffold", - "template", - "verb", - "vinyl" - ], - "plugins": [ - "gulp-format-md" - ], - "data": { - "author": { - "username": "jonschlinkert" - } - } - }, - "update": { - "note": "this is just pseudo data for tests. I'll update with real stuff soon.", - "cwd": "lib/pipeline", - "helpers": { - "related": "@/helper-related" - }, - "plugins": { - "./lib/pipeline/a": {}, - "./lib/pipeline/b": {}, - "./lib/pipeline/c": {} - }, - "set": { - "aaa": "yyy" - } - } -} diff --git a/vendors/update/test/app.applyLayout.js b/vendors/update/test/app.applyLayout.js deleted file mode 100644 index 7c8d7824..00000000 --- a/vendors/update/test/app.applyLayout.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; -var page = { - content: '<%= name %>', - layout: 'default.tmpl', - locals: { - name: 'Halle' - } -}; - -describe('helpers', function() { - describe('rendering', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('layout', { viewType: 'layout' }); - app.create('page'); - }); - - it('should throw an error when a layout cannot be found:', function(cb) { - app.layout('fofof.tmpl', {content: '..'}); - app.page('a.tmpl', page) - .render(function(err) { - assert.equal(err.message, 'Templates#layouts layout "default.tmpl" was defined on view "a.tmpl"\nbut cannot be not found (common causes are incorrect glob patterns,\nrenameKey function modifying the key, and typos in search pattern)'); - cb(); - }); - }); - - it('should emit an error when a layout cannot be found:', function(cb) { - app.layout('fofof.tmpl', {content: '..'}); - app.on('error', function(err) { - assert.equal(err.message, 'Templates#layouts layout "default.tmpl" was defined on view "a.tmpl"\nbut cannot be not found (common causes are incorrect glob patterns,\nrenameKey function modifying the key, and typos in search pattern)'); - cb(); - }); - - app.page('a.tmpl', page) - .render(function() { - }); - }); - - it('should throw an error - layout defined but no layouts registered:', function(cb) { - app.page('a.tmpl', page) - .render(function(err) { - assert.equal(err.message, 'Templates#layouts layout "default.tmpl" was defined on view "a.tmpl"\nbut cannot be not found (common causes are incorrect glob patterns,\nrenameKey function modifying the key, and typos in search pattern)'); - cb(); - }); - }); - - it('should emit an error - layout defined but no layouts registered:', function(cb) { - app.on('error', function(err) { - assert.equal(err.message, 'Templates#layouts layout "default.tmpl" was defined on view "a.tmpl"\nbut cannot be not found (common causes are incorrect glob patterns,\nrenameKey function modifying the key, and typos in search pattern)'); - cb(); - }); - app.page('a.tmpl', page) - .render(function() { - }); - }); - - it('should wrap a view with a layout (view.render):', function(cb) { - app.layout('default.tmpl', {content: 'before {% body %} after'}); - app.page('a.tmpl', page) - .render(function(err) { - if (err) return cb(err); - cb(); - }); - }); - - it('should wrap a view with a layout (app.render):', function(cb) { - app.layout('default.tmpl', {content: 'before {% body %} after'}); - app.page('a.tmpl', page); - - var view = app.pages.getView('a.tmpl'); - app.render(view, function(err, res) { - if (err) return cb(err); - assert(res.contents.toString() === 'before Halle after'); - cb(); - }); - }); - }); -}); - diff --git a/vendors/update/test/app.collection.compile.js b/vendors/update/test/app.collection.compile.js deleted file mode 100644 index 1ceed4ea..00000000 --- a/vendors/update/test/app.collection.compile.js +++ /dev/null @@ -1,50 +0,0 @@ -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Views = App.Views; -var views; - -describe('compile', function() { - beforeEach(function() { - views = new Views(); - }); - - it('should throw an error when an engine cannot be found:', function() { - views.addView('foo.bar', {content: '<%= name %>'}); - var page = views.getView('foo.bar'); - (function() { - views.compile(page); - }).should.throw('Views#compile cannot find an engine for: .bar'); - }); - - it('should compile a template:', function() { - views.engine('tmpl', require('engine-base')); - views.addView('a.tmpl', {path: 'a.tmpl', content: '<%= a %>', a: 'b'}); - - var page = views.getView('a.tmpl'); - var view = views.compile(page); - assert.equal(typeof view.fn, 'function'); - }); - - it('should compile a template by name:', function() { - views.engine('tmpl', require('engine-base')); - views.addView('a.tmpl', {path: 'a.tmpl', content: '<%= a %>', a: 'b'}); - - var view = views.compile('a.tmpl'); - assert.equal(typeof view.fn, 'function'); - }); - - it('should throw an error when a callback is given:', function() { - views.engine('md', require('engine-base')); - views.addView('foo.md', {content: '<%= name %>'}); - var page = views.getView('foo.md'); - (function() { - views.compile(page, function() {}); - }).should.throw('Views#compile is sync and does not take a callback function'); - - (function() { - views.compile(page, {}, function() {}); - }).should.throw('Views#compile is sync and does not take a callback function'); - }); -}); diff --git a/vendors/update/test/app.collection.js b/vendors/update/test/app.collection.js deleted file mode 100644 index ef8c5480..00000000 --- a/vendors/update/test/app.collection.js +++ /dev/null @@ -1,186 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var define = require('define-property'); -var support = require('./support'); -var App = support.resolve(); -var Collection = App.Collection; -var app; - -describe('collection', function() { - describe('method', function() { - beforeEach(function() { - app = new App(); - }); - - it('should expose the collection method', function() { - assert(typeof app.collection === 'function'); - }); - - it('should return a new collection', function() { - var collection = app.collection(); - assert(typeof collection === 'object'); - }); - - it('should have isCollection property', function() { - var collection = app.collection(); - assert(collection.isCollection === true); - }); - }); - - describe('adding views', function() { - beforeEach(function() { - app = new App() - .use(function() { - return function() { - define(this, 'count', { - get: function() { - return Object.keys(this.views).length; - }, - set: function() { - throw new Error('count is a read-only getter and cannot be defined.'); - } - }); - }; - }); - - app.engine('tmpl', require('engine-base')); - app.create('pages', { - renameKey: function(fp) { - return path.relative(process.cwd(), fp); - } - }); - }); - - it('should load a view onto the respective collection:', function() { - app.pages('test/fixtures/pages/a.hbs'); - app.views.pages.should.have.property('test/fixtures/pages/a.hbs'); - }); - - it('should allow collection methods to be chained:', function() { - app - .pages('test/fixtures/pages/a.hbs') - .pages('test/fixtures/pages/b.hbs') - .pages('test/fixtures/pages/c.hbs'); - - app.views.pages.should.have.properties([ - 'test/fixtures/pages/a.hbs', - 'test/fixtures/pages/b.hbs', - 'test/fixtures/pages/c.hbs' - ]); - }); - - it('should expose the `option` method:', function() { - app.pages.option('foo', 'bar') - .pages('test/fixtures/pages/a.hbs') - .pages('test/fixtures/pages/b.hbs') - .pages('test/fixtures/pages/c.hbs'); - - app.pages.options.should.have.property('foo', 'bar'); - app.views.pages.should.have.properties([ - 'test/fixtures/pages/a.hbs', - 'test/fixtures/pages/b.hbs', - 'test/fixtures/pages/c.hbs' - ]); - }); - - it('should expose the `option` method:', function() { - app.pages.option('foo', 'bar') - .pages('test/fixtures/pages/a.hbs') - .pages('test/fixtures/pages/b.hbs') - .pages('test/fixtures/pages/c.hbs'); - - assert(app.pages.count === 3); - }); - }); - - describe('addItem', function() { - beforeEach(function() { - app = new App(); - }); - - it('should add items to a collection', function() { - var pages = app.collection({Collection: Collection}); - pages.addItem('foo'); - pages.addItem('bar'); - pages.addItem('baz'); - - pages.items.hasOwnProperty('foo'); - pages.items.hasOwnProperty('bar'); - pages.items.hasOwnProperty('baz'); - }); - - it('should create a collection from an existing collection:', function() { - var pages = app.collection({Collection: Collection}); - pages.addItem('foo'); - pages.addItem('bar'); - pages.addItem('baz'); - - var posts = app.collection(pages); - posts.items.hasOwnProperty('foo'); - posts.items.hasOwnProperty('bar'); - posts.items.hasOwnProperty('baz'); - }); - }); - - describe('rendering views', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('pages'); - app.cache.data = {}; - }); - - it('should render a view with inherited app.render', function(cb) { - app.page('test/fixtures/templates/a.tmpl') - .use(function(view) { - view.contents = fs.readFileSync(view.path); - }) - .set('data.name', 'Brian') - .render(function(err, res) { - if (err) return cb(err); - assert(res.content === 'Brian'); - cb(); - }); - }); - }); -}); - -describe('collection singular method', function() { - describe('create', function() { - beforeEach(function() { - app = new App(); - }); - - it('should add a pluralized collection from singular name', function() { - app.create('page'); - assert(typeof app.views.pages === 'object'); - }); - }); - - describe('adding views', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page', { - renameKey: function(fp) { - return path.relative(process.cwd(), fp); - } - }); - }); - - it('should add a view to the created collection:', function() { - app.page('test/fixtures/pages/a.hbs'); - assert(typeof app.views.pages['test/fixtures/pages/a.hbs'] === 'object'); - }); - - it('should expose the `option` method:', function() { - app.pages.option('foo', 'bar'); - app.pages.options.should.have.property('foo', 'bar'); - }); - }); -}); diff --git a/vendors/update/test/app.collection.render.js b/vendors/update/test/app.collection.render.js deleted file mode 100644 index 2d23152d..00000000 --- a/vendors/update/test/app.collection.render.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var async = require('async'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var pages, app; - -describe('render', function() { - describe('rendering', function() { - beforeEach(function() { - app = App(); - pages = app.create('pages'); - app.engine('tmpl', require('engine-base')); - pages.engine('tmpl', require('engine-base')); - }); - - it('should throw an error when no callback is given:', function() { - (function() { - app.pages.render({}); - }).should.throw('Views#render is async and expects a callback function'); - }); - - it('should throw an error when an engine is not defined:', function(done) { - pages.addView('foo.bar', { content: '<%= name %>' }); - var page = pages.getView('foo.bar'); - - app.pages.render(page, function(err) { - assert(err.message === 'Views#render cannot find an engine for: .bar'); - done(); - }); - }); - - it('should use helpers defined on app to render a view:', function(done) { - var locals = {name: 'Halle'}; - app.helper('upper', function(str) { - return str.toUpperCase(str) + 'app'; - }); - - pages.addView('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getView('a.tmpl'); - - app.render(page, function(err, res) { - if (err) return done(err); - - assert(res.content === 'a HALLEapp b'); - done(); - }); - }); - - it('should use helpers defined on app to render a view with collection.render:', function(done) { - var locals = {name: 'Halle'}; - app.helper('upper', function(str) { - return str.toUpperCase(str) + 'app'; - }); - - pages.addView('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - pages.helper('upper', app._.helpers.sync.upper); - var page = pages.getView('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - - assert(res.content === 'a HALLEapp b'); - done(); - }); - }); - - it('should use helpers when rendering a view:', function(done) { - var locals = {name: 'Halle'}; - pages.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - pages.addView('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getView('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - assert(res.content === 'a HALLE b'); - done(); - }); - }); - - it('should render a template when contents is a buffer:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = pages.getView('a.tmpl'); - - pages.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a template when content is a string:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = pages.getView('a.tmpl'); - - pages.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a view from its path:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - - pages.render('a.tmpl', function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use a plugin for rendering:', function(done) { - pages.engine('tmpl', require('engine-base')); - pages.option('engine', 'tmpl'); - - pages.addViews({ - 'a': {content: '<%= title %>', locals: {title: 'aaa'}}, - 'b': {content: '<%= title %>', locals: {title: 'bbb'}}, - 'c': {content: '<%= title %>', locals: {title: 'ccc'}}, - 'd': {content: '<%= title %>', locals: {title: 'ddd'}}, - 'e': {content: '<%= title %>', locals: {title: 'eee'}}, - 'f': {content: '<%= title %>', locals: {title: 'fff'}}, - 'g': {content: '<%= title %>', locals: {title: 'ggg'}}, - 'h': {content: '<%= title %>', locals: {title: 'hhh'}}, - 'i': {content: '<%= title %>', locals: {title: 'iii'}}, - 'j': {content: '<%= title %>', locals: {title: 'jjj'}} - }); - - pages.use(function(collection) { - collection.option('pager', false); - - collection.renderEach = function(cb) { - var list = new List(collection); - async.map(list.items, function(item, next) { - collection.render(item, next); - }, cb); - }; - }); - - pages.renderEach(function(err, items) { - if (err) return done(err); - assert(items[0].content === 'aaa'); - assert(items[9].content === 'jjj'); - assert(items.length === 10); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/app.compile.js b/vendors/update/test/app.compile.js deleted file mode 100644 index 090676e1..00000000 --- a/vendors/update/test/app.compile.js +++ /dev/null @@ -1,52 +0,0 @@ -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('compile', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - }); - - it('should throw an error when an engine cannot be found:', function() { - app.page('foo.bar', {content: '<%= name %>'}); - var page = app.pages.getView('foo.bar'); - (function() { - app.compile(page); - }).should.throw('Templates#compile cannot find an engine for: .bar'); - }); - - it('should compile a template:', function() { - app.engine('tmpl', require('engine-base')); - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>', a: 'b'}); - - var page = app.pages.getView('a.tmpl'); - var view = app.compile(page); - assert.equal(typeof view.fn, 'function'); - }); - - it('should compile a template by name:', function() { - app.engine('tmpl', require('engine-base')); - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>', a: 'b'}); - - var view = app.compile('a.tmpl'); - assert.equal(typeof view.fn, 'function'); - }); - - it('should throw an error when a callback is given:', function() { - app.engine('md', require('engine-base')); - app.page('foo.md', {content: '<%= name %>'}); - var page = app.pages.getView('foo.md'); - (function() { - app.compile(page, function() { - }); - }).should.throw('Templates#compile is sync and does not take a callback function'); - - (function() { - app.compile(page, {}, function() { - }); - }).should.throw('Templates#compile is sync and does not take a callback function'); - }); -}); diff --git a/vendors/update/test/app.copy.js b/vendors/update/test/app.copy.js deleted file mode 100644 index cf18b8c7..00000000 --- a/vendors/update/test/app.copy.js +++ /dev/null @@ -1,31 +0,0 @@ -require('mocha'); -var path = require('path'); -var assert = require('assert'); -var rimraf = require('rimraf'); -var App = require('..'); -var app; - -var fixtures = path.join(__dirname, 'fixtures/copy/*.txt'); -var actual = path.join(__dirname, 'actual'); - -describe('copy()', function() { - beforeEach(function(done) { - rimraf(actual, done); - app = new App(); - }); - - afterEach(function(done) { - rimraf(actual, done); - }); - - describe('streams', function() { - it('should copy files', function(done) { - app.copy(fixtures, path.join(__dirname, 'actual')) - .on('error', done) - .on('data', function(file) { - assert.equal(typeof file, 'object'); - }) - .on('end', done); - }); - }); -}); diff --git a/vendors/update/test/app.create.js b/vendors/update/test/app.create.js deleted file mode 100644 index 5486eb20..00000000 --- a/vendors/update/test/app.create.js +++ /dev/null @@ -1,244 +0,0 @@ -require('mocha'); -require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('create', function() { - describe('inflections', function() { - beforeEach(function() { - app = new App(); - }); - - it('should expose the create method', function() { - assert(typeof app.create === 'function'); - }); - - it('should add a collection to `views`', function() { - app.create('pages'); - assert(typeof app.views.pages === 'object'); - assert(typeof app.pages === 'function'); - }); - - it('should add a pluralized collection to `views`', function() { - app.create('page'); - assert(typeof app.views.pages === 'object'); - assert(typeof app.page === 'function'); - }); - }); - - describe('renderable views', function() { - beforeEach(function() { - app = new App(); - app.create('pages'); - app.create('partials', {viewType: 'partial'}); - app.create('layout', {viewType: 'layout'}); - }); - - it('should add renderable views when no type is defined', function() { - app.pages.addView('foo', {content: 'bar'}); - assert(app.views.pages.hasOwnProperty('foo')); - }); - - it('should add view Ctor names to views', function() { - app.pages.addView('foo', {content: 'bar'}); - assert(app.views.pages.foo._name === 'Page'); - }); - - it('should add partial views when partial type is defined', function() { - app.partials.addView('abc', {content: 'xyz'}); - assert(app.views.partials.hasOwnProperty('abc')); - }); - - it('should add layout views when layout type is defined', function() { - app.layouts.addView('foo', {content: 'bar'}); - assert(app.views.layouts.hasOwnProperty('foo')); - }); - - it('should set viewType on renderable views', function() { - app.pages.addView('foo', {content: 'bar'}); - var view = app.pages.getView('foo'); - assert(view.isType('renderable')); - assert(!view.isType('layout')); - assert(!view.isType('partial')); - }); - - it('should set viewType on partial views', function() { - app.partials.addView('foo', {content: 'bar'}); - var view = app.partials.getView('foo'); - assert(view.isType('partial')); - assert(!view.isType('layout')); - assert(!view.isType('renderable')); - }); - - it('should set viewType on layout views', function() { - app.layouts.addView('foo', {content: 'bar'}); - var view = app.layouts.getView('foo'); - assert(view.isType('layout')); - assert(!view.isType('renderable')); - assert(!view.isType('partial')); - }); - }); - - describe('custom constructors', function() { - beforeEach(function() { - var Vinyl = require('vinyl'); - Vinyl.prototype.custom = function(key) { - this[key] = 'nonsense'; - return this; - }; - app = new App({View: Vinyl}); - app.create('pages'); - }); - - it('should create views from key-value pairs:', function() { - app.page('a.hbs', {path: 'a.hbs', content: 'a'}); - app.page('b.hbs', {path: 'b.hbs', content: 'b'}); - app.page('c.hbs', {path: 'c.hbs', content: 'c'}); - var a = app.pages.getView('a.hbs'); - a.custom('foo'); - a.foo.should.equal('nonsense'); - }); - }); - - describe('custom instances', function() { - it('should create views from custom `View` and `Views` instance/ctor:', function() { - var Vinyl = require('vinyl'); - Vinyl.prototype.read = function(file) { - return fs.readFileSync(file.path); - }; - - var Views = App.Views; - var views = new Views({View: Vinyl}); - - views.addView('a.hbs', {path: 'a.hbs', content: 'a'}); - views.addView('b.hbs', {path: 'b.hbs', content: 'b'}); - views.addView('c.hbs', {path: 'c.hbs', content: 'c'}); - - app = new App(); - app.create('pages', views); - - var a = app.pages.getView('a.hbs'); - assert(a instanceof Vinyl); - assert(Vinyl.isVinyl(a)); - assert(typeof a.read === 'function'); - - views.addView('d.hbs', {path: 'd.hbs', content: 'd'}); - var d = app.pages.getView('d.hbs'); - assert(d instanceof Vinyl); - assert(Vinyl.isVinyl(d)); - }); - }); - - describe('chaining', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page', { - renameKey: function(fp) { - return path.relative(process.cwd(), fp); - } - }); - }); - - it('should create views from key-value pairs:', function() { - app.page('a.hbs', {content: 'a'}); - app.page('b.hbs', {content: 'b'}); - app.page('c.hbs', {content: 'c'}); - app.views.pages.should.have.properties(['a.hbs', 'b.hbs', 'c.hbs']); - assert(app.views.pages['a.hbs'].contents.toString() === 'a'); - }); - - it('should create views from file paths:', function() { - app.page('test/fixtures/pages/a.hbs'); - app.page('test/fixtures/pages/b.hbs'); - app.page('test/fixtures/pages/c.hbs'); - - app.views.pages.should.have.properties([ - 'test/fixtures/pages/a.hbs', - 'test/fixtures/pages/b.hbs', - 'test/fixtures/pages/c.hbs' - ]); - }); - }); - - describe('instance', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - }); - - it('should return the collection instance', function() { - var collection = app.create('pages'); - assert(collection instanceof App.Views); - - collection.option('renameKey', function(key) { - return path.basename(key); - }); - collection - .use(function(views) { - views.read = function(name) { - var view = this.getView(name); - view.contents = fs.readFileSync(view.path); - }; - }); - - collection.addView('test/fixtures/templates/a.tmpl'); - collection.read('a.tmpl'); - assert(collection.getView('a.tmpl').contents.toString() === '<%= name %>'); - }); - }); - - describe('viewType', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - }); - - it('should add collection to the given viewType', function() { - app.create('layout', {viewType: 'layout'}); - assert(app.layouts.options.viewType[0] === 'layout'); - }); - - it('should add a collection to multiple viewTypes', function() { - app.create('foo', {viewType: ['layout', 'renderable']}); - assert.deepEqual(app.foos.options.viewType, ['layout', 'renderable']); - }); - }); - - describe('events', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - }); - - it('should emit `create` when a collection is created:', function() { - app.on('create', function(collection) { - if (collection.options.plural === 'layouts') { - collection.options.foo = 'bar'; - } - }); - - app.create('layout'); - app.layout('one', {path: 'two', contents: '...'}); - assert(app.layouts.options.foo === 'bar'); - }); - }); - - describe('collection instantiation', function() { - it('should expose collection instance methods that are created after instantiation on the app collection loader', function() { - app.create('pages'); - app.pages.use(function(collection) { - collection.define('foo', function(msg) { - return 'foo ' + msg; - }); - }); - - assert(app.pages.foo); - assert(typeof app.pages.foo === 'function'); - }); - }); -}); diff --git a/vendors/update/test/app.data.js b/vendors/update/test/app.data.js deleted file mode 100644 index f3a1992b..00000000 --- a/vendors/update/test/app.data.js +++ /dev/null @@ -1,94 +0,0 @@ -require('mocha'); -require('should'); -var path = require('path'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('app.data', function() { - beforeEach(function() { - app = new App(); - }); - - it('should set a key-value pair on cache.data:', function() { - app.data('a', 'b'); - assert(app.cache.data.a === 'b'); - }); - - it('should set an object on cache.data:', function() { - app.data({c: 'd'}); - assert(app.cache.data.c === 'd'); - }); - - it('should load data from a file onto cache.data:', function() { - app.data('test/fixtures/data/a.json'); - assert(app.cache.data.a.one.a === 'aaa'); - }); - - it('should load a glob of data onto cache.data:', function() { - app.data('test/fixtures/data/*.json'); - assert(app.cache.data.a.one.a === 'aaa'); - assert(app.cache.data.b.two.b === 'bbb'); - assert(app.cache.data.c.three.c === 'ccc'); - }); - - it('should use `namespace` defined on global opts:', function() { - app.option('namespace', function(key) { - return 'prefix_' + path.basename(key, path.extname(key)); - }); - app.data('test/fixtures/data/*.json'); - assert(app.cache.data.prefix_a.one.a === 'aaa'); - assert(app.cache.data.prefix_b.two.b === 'bbb'); - assert(app.cache.data.prefix_c.three.c === 'ccc'); - }); - - it('should use `namespace` defined on data opts:', function() { - app.data('test/fixtures/data/*.json', { - namespace: function(key) { - return 'prefix_' + path.basename(key, path.extname(key)); - } - }); - assert(app.cache.data.prefix_a.one.a === 'aaa'); - assert(app.cache.data.prefix_b.two.b === 'bbb'); - assert(app.cache.data.prefix_c.three.c === 'ccc'); - }); - - it('should use `renameKey` defined on data opts:', function() { - app.data('test/fixtures/data/*.json', { - renameKey: function(key) { - return 'prefix_' + path.basename(key, path.extname(key)); - } - }); - assert(app.cache.data.prefix_a.one.a === 'aaa'); - assert(app.cache.data.prefix_b.two.b === 'bbb'); - assert(app.cache.data.prefix_c.three.c === 'ccc'); - }); - - it('should extend `cache.data`', function() { - app.data({a: 'aaa', b: 'bbb', c: 'ccc'}); - app.data({x: 'xxx', y: 'yyy', z: 'zzz'}); - assert(app.cache.data.a === 'aaa'); - assert(app.cache.data.b === 'bbb'); - assert(app.cache.data.c === 'ccc'); - assert(app.cache.data.x === 'xxx'); - assert(app.cache.data.y === 'yyy'); - assert(app.cache.data.z === 'zzz'); - }); - - it('should extend the `cache.data` object when the first param is a string.', function() { - app.data('foo', {x: 'xxx', y: 'yyy', z: 'zzz'}); - app.data('bar', {a: 'aaa', b: 'bbb', c: 'ccc'}); - assert(app.cache.data.foo.x === 'xxx'); - assert(app.cache.data.bar.a === 'aaa'); - }); - - it('should be chainable.', function() { - app - .data({x: 'xxx', y: 'yyy', z: 'zzz'}) - .data({a: 'aaa', b: 'bbb', c: 'ccc'}); - - assert(app.cache.data.x === 'xxx'); - assert(app.cache.data.a === 'aaa'); - }); -}); diff --git a/vendors/update/test/app.dest.js b/vendors/update/test/app.dest.js deleted file mode 100644 index ff285e82..00000000 --- a/vendors/update/test/app.dest.js +++ /dev/null @@ -1,1103 +0,0 @@ -var spies = require('./support/spy'); -var chmodSpy = spies.chmodSpy; -var statSpy = spies.statSpy; - -require('mocha'); -var should = require('should'); -var assert = require('assert'); -var App = require('..'); -var app; - -var path = require('path'); -var fs = require('graceful-fs'); -var rimraf = require('rimraf'); - -var bufferStream; -var bufEqual = require('buffer-equal'); -var through = require('through2'); -var File = require('vinyl'); - -var actual = path.join(__dirname, 'actual'); - -var wipeOut = function(cb) { - app = new App(); - rimraf(path.join(__dirname, 'actual/'), cb); - spies.setError('false'); - statSpy.reset(); - chmodSpy.reset(); -}; - -var dataWrap = function(fn) { - return function(data, enc, cb) { - fn(data); - cb(); - }; -}; - -var realMode = function(n) { - return n & 07777; -}; - -describe('dest stream', function() { - beforeEach(wipeOut); - afterEach(wipeOut); - - it('should explode on invalid folder (empty)', function(done) { - var stream; - try { - stream = app.dest(); - } catch (err) { - assert(err && typeof err === 'object'); - should.not.exist(stream); - done(); - } - }); - - it('should explode on invalid folder (empty string)', function(done) { - var stream; - try { - stream = app.dest(''); - } catch (err) { - assert(err && typeof err === 'object'); - should.not.exist(stream); - done(); - } - }); - - it('should pass through writes with cwd', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - - var expectedFile = new File({ - base: __dirname, - cwd: __dirname, - path: inputPath, - contents: null - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - done(); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should pass through writes with default cwd', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - - var expectedFile = new File({ - base: __dirname, - cwd: __dirname, - path: inputPath, - contents: null - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - done(); - }; - - var stream = app.dest(path.join(__dirname, 'actual/')); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should not write null files', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: null - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(false); - done(); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write buffer files to the right folder with relative cwd', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - var expectedContents = fs.readFileSync(inputPath); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - done(); - }; - - var stream = app.dest('./actual/', {cwd: path.relative(process.cwd(), __dirname)}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write buffer files to the right folder with function and relative cwd', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - var expectedContents = fs.readFileSync(inputPath); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - done(); - }; - - var stream = app.dest(function(file){ - should.exist(file); - file.should.equal(expectedFile); - return './actual'; - }, {cwd: path.relative(process.cwd(), __dirname)}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write buffer files to the right folder', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0655; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write streaming files to the right folder', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0655; - - var contentStream = through.obj(); - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: contentStream, - stat: { - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - setTimeout(function(){ - contentStream.write(expectedContents); - contentStream.end(); - }, 100); - stream.end(); - }); - - it('should write directories to the right folder', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test'); - var expectedCwd = __dirname; - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0655; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: null, - stat: { - isDirectory: function(){ - return true; - }, - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - fs.lstatSync(expectedPath).isDirectory().should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should allow piping multiple dests in streaming mode', function(done) { - var inputPath1 = path.join(__dirname, 'actual/multiple-first'); - var inputPath2 = path.join(__dirname, 'actual/multiple-second'); - var inputBase = path.join(__dirname, 'actual/'); - var srcPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var stream1 = app.dest('./actual/', {cwd: __dirname}); - var stream2 = app.dest('./actual/', {cwd: __dirname}); - var content = fs.readFileSync(srcPath); - var rename = through.obj(function(file, _, next) { - file.path = inputPath2; - this.push(file); - next(); - }); - - stream1.on('data', function(file) { - file.path.should.equal(inputPath1); - }); - - stream1.pipe(rename).pipe(stream2); - stream2.on('data', function(file) { - file.path.should.equal(inputPath2); - }).once('end', function() { - fs.readFileSync(inputPath1, 'utf8').should.equal(content.toString()); - fs.readFileSync(inputPath2, 'utf8').should.equal(content.toString()); - done(); - }); - - var file = new File({ - base: inputBase, - path: inputPath1, - cwd: __dirname, - contents: content - }); - - stream1.write(file); - stream1.end(); - }); - - it('should write new files with the default user mode', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedMode = 0666 & (~process.umask()); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - fs.existsSync(expectedPath).should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - chmodSpy.reset(); - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write new files with the specified mode', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedMode = 0744; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - fs.existsSync(expectedPath).should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - chmodSpy.reset(); - var stream = app.dest('./actual/', {cwd: __dirname, mode:expectedMode}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should update file mode to match the vinyl mode', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var startMode = 0655; - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - var onEnd = function(){ - assert(chmodSpy.called); - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - fs.existsSync(expectedPath).should.equal(true); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - fs.chmodSync(expectedPath, startMode); - - chmodSpy.reset(); - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should use different modes for files and directories', function(done) { - var inputBase = path.join(__dirname, 'fixtures/vinyl'); - var inputPath = path.join(__dirname, 'fixtures/vinyl/wow/suchempty'); - var expectedBase = path.join(__dirname, 'actual/wow'); - var expectedDirMode = 0755; - var expectedFileMode = 0655; - - var firstFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - stat: fs.statSync(inputPath) - }); - - var onEnd = function(){ - realMode(fs.lstatSync(expectedBase).mode).should.equal(expectedDirMode); - realMode(buffered[0].stat.mode).should.equal(expectedFileMode); - done(); - }; - - var stream = app.dest('./actual/', { - cwd: __dirname, - mode: expectedFileMode, - dirMode: expectedDirMode - }); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(firstFile); - stream.end(); - }); - - it('should change to the specified base as string', function(done) { - var inputBase = path.join(__dirname, 'fixtures/vinyl'); - var inputPath = path.join(__dirname, 'fixtures/vinyl/wow/suchempty'); - - var firstFile = new File({ - cwd: __dirname, - path: inputPath, - stat: fs.statSync(inputPath) - }); - - var onEnd = function(){ - buffered[0].base.should.equal(inputBase); - done(); - }; - - var stream = app.dest('./actual/', { - cwd: __dirname, - base: inputBase - }); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(firstFile); - stream.end(); - }); - - it('should change to the specified base as function', function(done) { - var inputBase = path.join(__dirname, 'fixtures/vinyl'); - var inputPath = path.join(__dirname, 'fixtures/vinyl/wow/suchempty'); - - var firstFile = new File({ - cwd: __dirname, - path: inputPath, - stat: fs.statSync(inputPath) - }); - - var onEnd = function() { - buffered[0].base.should.equal(inputBase); - done(); - }; - - var stream = app.dest('./actual/', { - cwd: __dirname, - base: function(file){ - should.exist(file); - file.path.should.equal(inputPath); - return inputBase; - } - }); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(firstFile); - stream.end(); - }); - - it('should report IO errors', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - fs.chmodSync(expectedPath, 0); - - var stream = app.dest('./actual/', {cwd: __dirname}); - stream.on('error', function(err) { - err.code.should.equal('EACCES'); - done(); - }); - stream.write(expectedFile); - }); - - it('should report stat errors', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - - spies.setError(function(mod, fn) { - if (fn === 'stat' && arguments[2] === expectedPath) { - return new Error('stat error'); - } - }); - - var stream = app.dest('./actual/', {cwd: __dirname}); - stream.on('error', function(err) { - err.message.should.equal('stat error'); - done(); - }); - stream.write(expectedFile); - }); - - it('should report chmod errors', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - - spies.setError(function(mod, fn) { - if (fn === 'chmod' && arguments[2] === expectedPath) { - return new Error('chmod error'); - } - }); - - var stream = app.dest('./actual/', {cwd: __dirname}); - stream.on('error', function(err) { - err.message.should.equal('chmod error'); - done(); - }); - stream.write(expectedFile); - }); - - it('should not chmod a matching file', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - var expectedCount = 0; - spies.setError(function(mod, fn) { - if (fn === 'stat' && arguments[2] === expectedPath) { - expectedCount++; - } - }); - - var onEnd = function(){ - expectedCount.should.equal(1); - assert(!chmodSpy.called); - realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); - done(); - }; - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - fs.chmodSync(expectedPath, expectedMode); - - statSpy.reset(); - chmodSpy.reset(); - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should see a file with special chmod (setuid/setgid/sticky) as matching', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, 'actual'); - var expectedMode = 03722; - var normalMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: normalMode - } - }); - - var expectedCount = 0; - spies.setError(function(mod, fn) { - if (fn === 'stat' && arguments[2] === expectedPath) { - expectedCount++; - } - }); - - var onEnd = function(){ - expectedCount.should.equal(1); - assert(!chmodSpy.called); - done(); - }; - - fs.mkdirSync(expectedBase); - fs.closeSync(fs.openSync(expectedPath, 'w')); - fs.chmodSync(expectedPath, expectedMode); - - statSpy.reset(); - chmodSpy.reset(); - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should not overwrite files with overwrite option set to false', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var inputContents = fs.readFileSync(inputPath); - - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedBase = path.join(__dirname, 'actual'); - var existingContents = 'Lorem Ipsum'; - - var inputFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: inputContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - bufEqual(fs.readFileSync(expectedPath), new Buffer(existingContents)).should.equal(true); - done(); - }; - - // Write expected file which should not be overwritten - fs.mkdirSync(expectedBase); - fs.writeFileSync(expectedPath, existingContents); - - var stream = app.dest('./actual/', {cwd: __dirname, overwrite: false}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(inputFile); - stream.end(); - }); - - it('should overwrite files with overwrite option set to true', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var inputContents = fs.readFileSync(inputPath); - - var expectedPath = path.join(__dirname, 'actual/test.coffee'); - var expectedBase = path.join(__dirname, 'actual'); - var existingContents = 'Lorem Ipsum'; - - var inputFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: inputContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - bufEqual(fs.readFileSync(expectedPath), new Buffer(inputContents)).should.equal(true); - done(); - }; - - // This should be overwritten - fs.mkdirSync(expectedBase); - fs.writeFileSync(expectedPath, existingContents); - - var stream = app.dest('./actual/', {cwd: __dirname, overwrite: true}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(inputFile); - stream.end(); - }); - - it('should create symlinks when the `symlink` attribute is set on the file', function(done) { - var inputPath = path.join(__dirname, 'fixtures/vinyl/test-create-dir-symlink'); - var inputBase = path.join(__dirname, 'fixtures/vinyl/'); - var inputRelativeSymlinkPath = 'wow'; - - var expectedPath = path.join(__dirname, 'actual/test-create-dir-symlink'); - - var inputFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: null, //'' - }); - - // `src()` adds this side-effect with `keepSymlinks` option set to false - inputFile.symlink = inputRelativeSymlinkPath; - - var onEnd = function(){ - fs.readlink(buffered[0].path, function() { - buffered[0].symlink.should.equal(inputFile.symlink); - buffered[0].path.should.equal(expectedPath); - done(); - }); - }; - - var stream = app.dest('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(inputFile); - stream.end(); - }); - - it('should emit finish event', function(done) { - var srcPath = path.join(__dirname, 'fixtures/vinyl/test.coffee'); - var stream = app.dest('./actual/', {cwd: __dirname}); - - stream.once('finish', function() { - done(); - }); - - var file = new File({ - path: srcPath, - cwd: __dirname, - contents: new Buffer("1234567890") - }); - - stream.write(file); - stream.end(); - }); -}); - -describe('dest', function() { - beforeEach(function(done) { - rimraf(actual, done); - app = new App(); - }); - - afterEach(function(done) { - rimraf(actual, done); - }); - - describe('streams', function() { - it('should return a stream', function(done) { - var stream = app.dest(path.join(__dirname, 'fixtures/')); - should.exist(stream); - should.exist(stream.on); - done(); - }); - - it('should return an output stream that writes files', function(done) { - var instream = app.src(path.join(__dirname, 'fixtures/copy/e*.txt')); - var outstream = app.dest(actual); - instream.pipe(outstream); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - path.join(file.path, '').should.equal(path.join(actual, 'example.txt')); - String(file.contents).should.equal('Hello world!'); - }); - outstream.on('end', function() { - fs.readFile(path.join(actual, 'example.txt'), function(err, contents) { - should.not.exist(err); - should.exist(contents); - String(contents).should.equal('Hello world!'); - done(); - }); - }); - }); - - it('should return an output stream that does not write non-read files', function(done) { - var instream = app.src(path.join(__dirname, 'fixtures/copy/e*.txt'), {read: false}); - var outstream = app.dest(actual); - instream.pipe(outstream); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - should.not.exist(file.contents); - path.join(file.path, '').should.equal(path.join(actual, 'example.txt')); - }); - - outstream.on('end', function() { - fs.readFile(path.join(actual, 'example.txt'), function(err, contents) { - should.exist(err); - should.not.exist(contents); - done(); - }); - }); - }); - - it('should return an output stream that writes streaming files', function(done) { - var instream = app.src(path.join(__dirname, 'fixtures/copy/e*.txt'), {buffer: false}); - var outstream = instream.pipe(app.dest(actual)); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - path.join(file.path, '').should.equal(path.join(actual, 'example.txt')); - }); - outstream.on('end', function() { - fs.readFile(path.join(actual, 'example.txt'), function(err, contents) { - should.not.exist(err); - should.exist(contents); - String(contents).should.equal('Hello world!'); - done(); - }); - }); - }); - - it('should return an output stream that writes streaming files to new directories', function(done) { - testWriteDir({}, done); - }); - - it('should return an output stream that writes streaming files to new directories (buffer: false)', function(done) { - testWriteDir({buffer: false}, done); - }); - - it('should return an output stream that writes streaming files to new directories (read: false)', function(done) { - testWriteDir({read: false}, done); - }); - - it('should return an output stream that writes streaming files to new directories (read: false, buffer: false)', function(done) { - testWriteDir({buffer: false, read: false}, done); - }); - - }); - - describe('ext', function() { - beforeEach(function() { - app = new App(); - app.set('ext', '.txt'); - }); - - afterEach(function() { - app.set('ext', '.html'); - }); - - it('should return a stream', function(done) { - var stream = app.dest(path.join(__dirname, 'fixtures/')); - should.exist(stream); - should.exist(stream.on); - done(); - }); - - it('should return an output stream that writes files', function(done) { - var instream = app.src(path.join(__dirname, 'fixtures/copy/e*.txt')); - var outstream = app.dest(actual); - instream.pipe(outstream); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - path.join(file.path, '').should.equal(path.join(actual, 'example.txt')); - String(file.contents).should.equal('Hello world!'); - }); - outstream.on('end', function() { - fs.readFile(path.join(actual, 'example.txt'), function(err, contents) { - should.not.exist(err); - should.exist(contents); - String(contents).should.equal('Hello world!'); - done(); - }); - }); - }); - - it('should return an output stream that does not write non-read files', function(done) { - var instream = app.src(path.join(__dirname, 'fixtures/dest/*.txt'), {read: false}); - var outstream = app.dest(actual); - instream.pipe(outstream); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - should.not.exist(file.contents); - path.join(file.path, '').should.equal(path.join(actual, 'example.txt')); - }); - - outstream.on('end', function() { - fs.readFile(path.join(actual, 'example.txt'), function(err, contents) { - should.exist(err); - should.not.exist(contents); - done(); - }); - }); - }); - }); - - function testWriteDir(srcOptions, done) { - var instream = app.src(path.join(__dirname, 'fixtures/generic'), srcOptions); - var outstream = instream.pipe(app.dest(actual)); - - outstream.on('error', done); - outstream.on('data', function(file) { - // data should be re-emitted correctly - should.exist(file); - should.exist(file.path); - path.join(file.path,'').should.equal(path.join(actual, 'generic')); - }); - - outstream.on('end', function() { - fs.exists(path.join(actual, 'generic'), function(exists) { - /* jshint expr: true */ - should(exists).be.ok; - /* jshint expr: false */ - done(); - }); - }); - } -}); - diff --git a/vendors/update/test/app.engines.js b/vendors/update/test/app.engines.js deleted file mode 100644 index 16bd062c..00000000 --- a/vendors/update/test/app.engines.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('engine support', function() { - beforeEach(function() { - app = new App(); - }); - - it('should throw an error when engine name is invalid:', function() { - (function() { - app.engine(null, {}); - }).should.throw('expected engine ext to be a string or array.'); - }); - - it('should register an engine to the given extension', function() { - app.engine('hbs', function() {}); - assert(typeof app.engines['.hbs'] === 'object'); - }); - - it('should set an engine with the given extension', function() { - var hbs = function() {}; - hbs.render = function() {}; - hbs.renderFile = function() {}; - app.engine('hbs', hbs); - assert(app.engines['.hbs']); - assert(app.engines['.hbs'].renderFile); - assert(app.engines['.hbs'].render); - }); - - it('should get an engine:', function() { - app.engine('hbs', function() {}); - var hbs = app.engine('hbs'); - assert(typeof hbs === 'object'); - assert(hbs.hasOwnProperty('render')); - assert(hbs.hasOwnProperty('compile')); - }); - - it('should return undefined if no engine is found:', function() { - var hbs = app.getEngine(); - assert.equal(typeof hbs, 'undefined'); - }); - - it('should register multiple engines to the given extension', function() { - app.engine(['hbs', 'md'], function() {}); - assert(typeof app.engines['.hbs'] === 'object'); - assert(typeof app.engines['.md'] === 'object'); - }); -}); - -describe('engines', function() { - beforeEach(function() { - app = new App(); - app.create('pages'); - app.pages('foo.tmpl', {content: 'A <%= letter %> {{= letter }} C'}); - app.pages('bar.tmpl', {content: 'A <%= letter %> {{ letter }} C'}); - }); - - it('should register an engine:', function() { - app.engine('a', {render: function() {}}); - app.engines.should.have.property('.a'); - }); - - it('should use custom delimiters:', function(cb) { - app.engine('tmpl', require('engine-base'), { - delims: ['{{', '}}'] - }); - app.render('foo.tmpl', {letter: 'B'}, function(err, res) { - if (err) return cb(err); - res.contents.toString().should.equal('A <%= letter %> B C'); - cb(); - }); - }); - - it('should override individual delims values:', function(cb) { - app.engine('tmpl', require('engine-base'), { - interpolate: /\{{([^}]+)}}/g, - evaluate: /\{{([^}]+)}}/g, - escape: /\{{-([^}]+)}}/g - }); - app.render('bar.tmpl', {letter: 'B'}, function(err, res) { - if (err) return cb(err); - res.contents.toString().should.equal('A <%= letter %> B C'); - cb(); - }); - }); - - it('should get an engine:', function() { - app.engine('a', { - render: function() {} - }); - var a = app.engine('a'); - a.should.have.property('render'); - }); -}); - -describe('engine selection:', function() { - beforeEach(function(cb) { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.engine('hbs', require('engine-handlebars')); - app.create('pages'); - cb(); - }); - - it('should get the engine from file extension:', function(cb) { - app.page('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return cb(err); - assert(view.content === 'b'); - cb(); - }); - }); - - it('should use the engine defined on the collection:', function(cb) { - app.create('posts', {engine: 'hbs'}); - - app.post('a', {content: '{{a}}', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return cb(err); - assert(view.content === 'b'); - cb(); - }); - }); - - it('should use the engine defined on the view:', function(cb) { - app.create('posts'); - app.post('a', {content: '{{a}}', engine: 'hbs', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return cb(err); - assert(view.content === 'b'); - cb(); - }); - }); - - it('should use the engine defined on `view.data`:', function(cb) { - app.create('posts'); - app.post('a', {content: '{{a}}', locals: {a: 'b'}, data: {engine: 'hbs'}}) - .render(function(err, view) { - if (err) return cb(err); - assert(view.content === 'b'); - cb(); - }); - }); - - it('should use the engine defined on render locals:', function(cb) { - app.create('posts'); - app.post('a', {content: '{{a}}', locals: {a: 'b'}}) - .render({engine: 'hbs'}, function(err, view) { - if (err) return cb(err); - assert(view.content === 'b'); - cb(); - }); - }); -}); diff --git a/vendors/update/test/app.events.js b/vendors/update/test/app.events.js deleted file mode 100644 index bae16fe2..00000000 --- a/vendors/update/test/app.events.js +++ /dev/null @@ -1,113 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('events', function() { - beforeEach(function() { - app = new App(); - }); - - it('should listen for an event:', function() { - var app = new App(); - app.on('foo', function() {}); - assert(Array.isArray(app._callbacks['$foo'])); - }); - - it('should emit an event:', function(done) { - var app = new App(); - app.on('foo', function(val) { - assert(val === 'bar'); - done(); - }); - assert(Array.isArray(app._callbacks['$foo'])); - app.emit('foo', 'bar'); - }); - - it('should listen for `view` events:', function() { - app = new App(); - - app.on('view', function(view) { - view.foo = 'bar'; - }); - - var view = app.view({path: 'a', content: 'b'}); - assert(view.foo === 'bar'); - }); -}); - -describe('onLoad', function() { - beforeEach(function() { - app = new App(); - }); - - describe('app.collection', function() { - it('should emit a `view` event when view is created', function(done) { - var collection = app.collection(); - - app.on('view', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - collection.addView('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - - it('should emit an onLoad event when view is created', function(done) { - var collection = app.collection(); - - app.on('onLoad', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - collection.addView('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - }); - - describe('view collections', function() { - it('should emit a view event when view is created', function(done) { - app.create('posts'); - - app.on('view', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - app.post('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - - it('should emit an onLoad event when view is created', function(done) { - app.create('posts'); - - app.on('onLoad', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - app.post('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - }); -}); diff --git a/vendors/update/test/app.get-set.js b/vendors/update/test/app.get-set.js deleted file mode 100644 index 8e8a5973..00000000 --- a/vendors/update/test/app.get-set.js +++ /dev/null @@ -1,72 +0,0 @@ -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('app.set()', function() { - beforeEach(function() { - app = new App(); - }); - - it('should set a value', function() { - app.set('a', 'b'); - app.get('a').should.equal('b'); - }); - - it('should set properties on the instance.', function() { - app.set('a', 'b'); - app.a.should.equal('b'); - }); - - it('should allow an object to be set directly.', function() { - app.set({x: 'y'}); - app.x.should.equal('y'); - app.get('x').should.equal('y'); - }); - - it('should set nested properties on the instance.', function() { - app.set('c', {d: 'e'}); - app.get('c').d.should.equal('e'); - }); - - it('should use dot notation to `set` values.', function() { - app.set('h.i', 'j'); - app.get('h').should.eql({i: 'j'}); - }); - - it('should use dot notation to `get` values.', function() { - app.set('h', {i: 'j'}); - app.get('h.i').should.equal('j'); - }); - - it('should return `this` for chaining', function() { - app.set('a', 'b').should.equal(app); - app - .set('aa', 'bb') - .set('bb', 'cc') - .set('cc', 'dd'); - app.get('aa').should.equal('bb'); - app.get('bb').should.equal('cc'); - app.get('cc').should.equal('dd'); - }); - - it('should return undefined when not set', function() { - app.set('a', undefined).should.equal(app); - }); -}); - -describe('app.get()', function() { - beforeEach(function() { - app = new App(); - }); - - it('should return undefined when no set', function() { - assert(app.get('a') === undefined); - }); - - it('should otherwise return the value', function() { - app.set('a', 'b'); - app.get('a').should.equal('b'); - }); -}); diff --git a/vendors/update/test/app.handle.js b/vendors/update/test/app.handle.js deleted file mode 100644 index d27d82dd..00000000 --- a/vendors/update/test/app.handle.js +++ /dev/null @@ -1,37 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('handler', function() { - beforeEach(function() { - app = new App(); - app.create('pages'); - app.handlers(['foo']); - }); - - it('should support custom handle methods:', function(done) { - var page = app.page('foo', {contents: null}); - - app.handle('foo', page, function(err, view) { - if (err) return done(err); - - assert(typeof view.path === 'string'); - done(); - }); - }); - - it('should not blow up if `options.handled` does not exist:', function(done) { - var page = app.page('foo', {contents: null}); - delete page.options.handled; - - app.handle('foo', page, function(err, view) { - if (err) return done(err); - - assert(typeof view.path === 'string'); - done(); - }); - }); -}); diff --git a/vendors/update/test/app.handlers.js b/vendors/update/test/app.handlers.js deleted file mode 100644 index f2b94d2c..00000000 --- a/vendors/update/test/app.handlers.js +++ /dev/null @@ -1,72 +0,0 @@ -require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var resolve = require('resolve-glob'); -var support = require('./support'); -var App = support.resolve(); -var app; - -function decorateViews(views) { - var fn = views.decorateView; - views.decorateView = function() { - var view = fn.apply(fn, arguments); - view.read = function() { - if (!this.contents) { - this.contents = fs.readFileSync(this.path); - } - }; - return view; - }; - views.loader = function(pattern) { - var files = resolve.sync(pattern); - return files.reduce(function(acc, fp) { - acc[fp] = {path: fp}; - return acc; - }, {}); - }; - return views; -} - -describe('handlers', function() { - describe('custom handlers', function() { - beforeEach(function() { - app = new App(); - app.create('pages') - .use(decorateViews) - .option('renameKey', function(key) { - return path.basename(key); - }); - }); - - it('should add custom middleware handlers:', function() { - app.handler('foo'); - app.router.should.have.property('foo'); - assert.equal(typeof app.router.foo, 'function'); - }); - - it('should add custom middleware handlers:', function() { - app.handler('foo'); - app.handler('bar'); - - app.foo(/./, function(view, next) { - view.one = 'aaa'; - next(); - }); - - app.bar(/./, function(view, next) { - view.two = 'zzz'; - next(); - }); - - app.page('abc', {content: '...'}) - .use(function(view) { - app.handleView('foo', view); - app.handleView('bar', view); - }); - - app.views.pages.abc.should.have.property('one', 'aaa'); - app.views.pages.abc.should.have.property('two', 'zzz'); - }); - }); -}); diff --git a/vendors/update/test/app.js b/vendors/update/test/app.js deleted file mode 100644 index 5ff835b0..00000000 --- a/vendors/update/test/app.js +++ /dev/null @@ -1,130 +0,0 @@ -/* deps: coveralls istanbul */ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Base = App.Base; -var app; - -describe('app', function() { - describe('constructor', function() { - it('should create an instance of App:', function() { - app = new App(); - assert(app instanceof App); - }); - - it('should new up without new:', function() { - app = App(); - assert(app instanceof App); - }); - }); - - describe('static methods', function() { - it('should expose `extend`:', function() { - assert(typeof App.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - app = new App(); - }); - - it('should expose `set`', function() { - assert(typeof app.set === 'function'); - }); - it('should expose `get`', function() { - assert(typeof app.get === 'function'); - }); - it('should expose `visit`', function() { - assert(typeof app.visit === 'function'); - }); - it('should expose `define`', function() { - assert(typeof app.define === 'function'); - }); - it('should expose `views`', function() { - assert(typeof app.views === 'object'); - }); - }); - - describe('instance', function() { - beforeEach(function() { - app = new App(); - }); - - it('should set a value on the instance:', function() { - app.set('a', 'b'); - assert(app.a === 'b'); - }); - - it('should get a value from the instance:', function() { - app.set('a', 'b'); - assert(app.get('a') === 'b'); - }); - }); - - describe('initialization', function() { - it('should listen for errors:', function(done) { - app = new App(); - app.on('error', function(err) { - assert(err.message === 'foo'); - done(); - }); - app.emit('error', new Error('foo')); - }); - - it('should mixin methods after init:', function() { - app = new App(); - app.option({ - mixins: { - foo: function() {} - } - }); - assert(typeof app.foo === 'function'); - }); - - it('should expose constructors from `lib`:', function() { - app = new App(); - app.expose('Collection'); - assert(typeof app.Collection === 'function'); - }); - - it('should update constructors after init:', function() { - var Group = App.Group; - function MyGroup() { - Base.call(this); - } - Base.extend(MyGroup); - - app = new App(); - assert.equal(app.Group, Group); - assert.equal(app.get('Group'), Group); - app.option('Group', MyGroup); - assert.equal(app.Group, MyGroup); - assert.equal(app.get('Group'), MyGroup); - }); - - it('should mixin prototype methods defined on options:', function() { - app = new App({ - mixins: { - foo: function() {} - } - }); - assert(typeof app.foo === 'function'); - delete App.prototype.foo; - }); - - it('should expose `_` on app:', function() { - app = new App(); - assert(typeof app._ === 'object'); - }); - - it('should not re-add `_` in init:', function() { - app = new App(); - app._.foo = 'bar'; - app.defaultConfig(); - assert(app._.foo === 'bar'); - }); - }); -}); diff --git a/vendors/update/test/app.list.compile.js b/vendors/update/test/app.list.compile.js deleted file mode 100644 index 1efa7919..00000000 --- a/vendors/update/test/app.list.compile.js +++ /dev/null @@ -1,44 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var list; - -describe('app.list.compile', function() { - beforeEach(function() { - list = new List(); - list.engine('tmpl', require('engine-base')); - }); - - it('should compile an item:', function() { - var buffer = new Buffer('a b c'); - var item = list.addItem('a.tmpl', {contents: buffer}) - .compile(); - - assert(typeof item.fn === 'function'); - }); - - it('should use the compiled function to render:', function() { - var buffer = new Buffer('a <%= title %> c'); - var item = list.addItem('a.tmpl', {contents: buffer}) - .compile(); - - assert(item.fn({title: 'z'})); - assert(typeof item.fn({title: 'z'}) === 'string'); - assert(item.fn({title: 'z'}) === 'a z c'); - }); - - it('should compile a view by name:', function() { - var buffer = new Buffer('a <%= title %> c'); - list.addItem('a.tmpl', {contents: buffer}); - - var item = list.compile('a.tmpl'); - - assert(item.fn({title: 'z'})); - assert(typeof item.fn({title: 'z'}) === 'string'); - assert(item.fn({title: 'z'}) === 'a z c'); - }); -}); - diff --git a/vendors/update/test/app.list.js b/vendors/update/test/app.list.js deleted file mode 100644 index 84527ec5..00000000 --- a/vendors/update/test/app.list.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var app; - -describe('list', function() { - describe('method', function() { - beforeEach(function() { - app = new App(); - }); - - it('should expose the list method', function() { - assert(typeof app.list === 'function'); - }); - - it('should return a new list', function() { - var list = app.list(); - assert(typeof list === 'object'); - }); - - it('should have isList property', function() { - var list = app.list(); - assert(list.isList === true); - }); - }); - - describe('adding items', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('pages', { - renameKey: function(fp) { - return path.relative(process.cwd(), fp); - } - }); - }); - - it('should add an item to a list:', function() { - app.pages('test/fixtures/pages/a.hbs'); - var list = app.list(); - list.addItem(app.pages.getView('test/fixtures/pages/a.hbs')); - assert(list.hasItem('test/fixtures/pages/a.hbs')); - }); - - it('should expose the `option` method from a list:', function() { - var list = app.list(); - list.option('a', 'b'); - assert(list.options); - assert(list.options.a === 'b'); - }); - }); - - describe('addItem', function() { - beforeEach(function() { - app = new App(); - }); - - it('should add items to a list', function() { - var pages = app.list({List: List}); - pages.addItem('foo'); - pages.addItem('bar'); - pages.addItem('baz'); - - pages.items.hasOwnProperty('foo'); - pages.items.hasOwnProperty('bar'); - pages.items.hasOwnProperty('baz'); - }); - - it('should create a list from an existing list:', function() { - var pages = app.list({List: List}); - pages.addItem('foo'); - pages.addItem('bar'); - pages.addItem('baz'); - - var posts = app.list(pages); - posts.items.hasOwnProperty('foo'); - posts.items.hasOwnProperty('bar'); - posts.items.hasOwnProperty('baz'); - }); - }); - - describe('rendering items', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('pages'); - }); - - it('should render a item with inherited app.render', function(done) { - app.page('test/fixtures/templates/a.tmpl') - .use(function(item) { - if (!item.content) { - item.contents = fs.readFileSync(item.path); - } - }) - .set('data.name', 'Brian') - .render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'Brian'); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/app.lookups.js b/vendors/update/test/app.lookups.js deleted file mode 100644 index afab53b6..00000000 --- a/vendors/update/test/app.lookups.js +++ /dev/null @@ -1,112 +0,0 @@ -require('mocha'); -require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var resolve = require('resolve-glob'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('lookups', function() { - beforeEach(function() { - app = new App(); - app.option('renameKey', function(key) { - return path.basename(key); - }); - app.create('pages') - .use(function(pages) { - pages.on('addViews', function(glob) { - var files = resolve.sync(glob); - files.forEach(function(fp) { - pages.addView(fp, {path: fp}); - }); - pages.loaded = true; - }); - return function(view) { - view.read = function() { - this.contents = fs.readFileSync(this.path); - }; - return view; - }; - }); - - app.pages('test/fixtures/templates/*.tmpl'); - }); - - describe('getView', function() { - it('should find a view', function() { - var view = app.getView('pages', 'a.tmpl'); - assert(typeof view.path === 'string'); - }); - - it('should find a view using the renameKey function', function() { - var view = app.getView('pages', 'test/fixtures/templates/a.tmpl'); - assert(typeof view.path === 'string'); - }); - - it('should return null when nothing is found', function() { - var view = app.getView('pages', 'test/fixtures/templates/foo.tmpl'); - assert(view === null); - }); - - it('should find a view using a glob pattern', function() { - var view = app.getView('pages', 'a', function(key) { - return key + '.tmpl'; - }); - assert(typeof view.path === 'string'); - }); - }); - - describe('getViews', function() { - it('should return the collection object if passed:', function() { - var views = app.getViews(app.views.pages); - assert(Object.keys(views).length > 1); - }); - - it('should return the specified collection with the plural name:', function() { - var views = app.getViews('pages'); - assert(Object.keys(views).length > 1); - }); - - it('should return the specified collection with the singular name:', function() { - var views = app.getViews('page'); - assert(Object.keys(views).length > 1); - }); - - it('should return null when the collection is not found:', function() { - (function() { - app.getViews('nada'); - }).should.throw('getViews cannot find collection: nada'); - }); - }); - - describe('find', function() { - it('should return null when a view is not found:', function() { - (function() { - app.find({}); - }).should.throw('expected name to be a string.'); - }); - - it('should find a view by collection name:', function() { - var view = app.find('a.tmpl', 'pages'); - assert(typeof view.path === 'string'); - }); - - it('should find a view by collection name:', function() { - app = new App(); - app.option('renameKey', function(key) { - return path.basename(key); - }); - app.create('pages'); - app.page('a/b/c.md', {content: '...'}); - var view = app.find('a/b/c.md'); - assert(typeof view.path === 'string'); - }); - - it('should find a view without a collection name:', function() { - var view = app.find('a.tmpl'); - assert(typeof view.path === 'string'); - }); - }); -}); diff --git a/vendors/update/test/app.middleware.js b/vendors/update/test/app.middleware.js deleted file mode 100644 index e32ca1a2..00000000 --- a/vendors/update/test/app.middleware.js +++ /dev/null @@ -1,60 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('middleware', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('pages'); - }); - - it('should call the all method for every middleware method:', function() { - var i = 0; - app.all(/./, function(view, next) { - assert(typeof view.path === 'string'); - i++; - next(); - }); - - assert(i === 0); - app.page('foo.tmpl', {content: 'foo'}); - assert(i === 1); - }); - - it('should call the onLoad method when a view is loaded:', function() { - var i = 0; - app.onLoad(/./, function(view, next) { - assert(typeof view.path === 'string'); - i++; - next(); - }); - - assert(i === 0); - app.page('foo.tmpl', {content: 'foo'}); - assert(i === 1); - }); - - it('should emit an event when a handler is called:', function(done) { - var i = 0; - app.on('onLoad', function() { - i++; - }); - app.on('preRender', function() { - i++; - }); - app.on('preCompile', function() { - i++; - }); - - app.page('foo.tmpl', {content: 'foo'}) - .render(function(err) { - if (err) return done(err); - assert(i === 3); - done(); - }); - }); -}); diff --git a/vendors/update/test/app.onLoad.js b/vendors/update/test/app.onLoad.js deleted file mode 100644 index 66bffbee..00000000 --- a/vendors/update/test/app.onLoad.js +++ /dev/null @@ -1,48 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('onLoad', function() { - beforeEach(function() { - app = new App(); - }); - - describe('app.collection', function() { - it('should emit an onLoad when view is created', function(done) { - var collection = app.collection(); - - app.on('onLoad', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - collection.addView('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - }); - - describe('view collections', function() { - it('should emit an onLoad when view is created', function(done) { - app.create('posts'); - - app.on('onLoad', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - app.post('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - }); -}); diff --git a/vendors/update/test/app.option.js b/vendors/update/test/app.option.js deleted file mode 100644 index c4043e7c..00000000 --- a/vendors/update/test/app.option.js +++ /dev/null @@ -1,98 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('app.option', function() { - beforeEach(function() { - app = new App(); - }); - - it('should set a key-value pair on options:', function() { - app.option('a', 'b'); - assert(app.options.a === 'b'); - }); - - it('should set an object on options:', function() { - app.option({c: 'd'}); - assert(app.options.c === 'd'); - }); - - it('should set an option.', function() { - app.option('a', 'b'); - app.options.should.have.property('a'); - }); - - it('should get an option.', function() { - app.option('a', 'b'); - app.option('a').should.equal('b'); - }); - - it('should extend the `options` object.', function() { - app.option({x: 'xxx', y: 'yyy', z: 'zzz'}); - app.option('x').should.equal('xxx'); - app.option('y').should.equal('yyy'); - app.option('z').should.equal('zzz'); - }); - - it('options should be on the `options` object.', function() { - app.option({x: 'xxx', y: 'yyy', z: 'zzz'}); - app.options.x.should.equal('xxx'); - app.options.y.should.equal('yyy'); - app.options.z.should.equal('zzz'); - }); - - it('should be chainable.', function() { - app.option({x: 'xxx', y: 'yyy', z: 'zzz'}); - app.option({a: 'aaa', b: 'bbb', c: 'ccc'}); - - app.option('x').should.equal('xxx'); - app.option('a').should.equal('aaa'); - }); - - it('should extend the `options` object when the first param is a string.', function() { - app.option('foo', {x: 'xxx', y: 'yyy', z: 'zzz'}); - app.option('bar', {a: 'aaa', b: 'bbb', c: 'ccc'}); - - app.option('foo').should.have.property('x'); - app.option('bar').should.have.property('a'); - - app.options.foo.should.have.property('x'); - app.options.bar.should.have.property('a'); - }); - - it('should set an option.', function() { - app.option('a', 'b'); - app.options.should.have.property('a'); - }); - - it('should get an option.', function() { - app.option('a', 'b'); - app.option('a').should.equal('b'); - }); - - it('should extend the `options` object.', function() { - app.option({x: 'xxx', y: 'yyy', z: 'zzz'}); - app.option('x').should.equal('xxx'); - app.option('y').should.equal('yyy'); - app.option('z').should.equal('zzz'); - }); - - it('options should be on the `options` object.', function() { - app.option({x: 'xxx', y: 'yyy', z: 'zzz'}); - app.options.x.should.equal('xxx'); - app.options.y.should.equal('yyy'); - app.options.z.should.equal('zzz'); - }); - - it('should be chainable.', function() { - app - .option({x: 'xxx', y: 'yyy', z: 'zzz'}) - .option({a: 'aaa', b: 'bbb', c: 'ccc'}); - - app.option('x').should.equal('xxx'); - app.option('a').should.equal('aaa'); - }); -}); diff --git a/vendors/update/test/app.render.js b/vendors/update/test/app.render.js deleted file mode 100644 index 98c194c3..00000000 --- a/vendors/update/test/app.render.js +++ /dev/null @@ -1,88 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('render', function() { - describe('rendering', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - it('should throw an error when no callback is given:', function() { - (function() { - app.render({}); - }).should.throw('Templates#render is async and expects a callback function'); - }); - - it('should throw an error when an engine is not defined:', function(done) { - app.page('foo.bar', {content: '<%= name %>'}); - var page = app.pages.getView('foo.bar'); - - app.render(page, function(err) { - assert(err.message === 'Templates#render cannot find an engine for: .bar'); - done(); - }); - }); - - it('should use helpers to render a view:', function(done) { - var locals = {name: 'Halle'}; - - app.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - app.page('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, res) { - if (err) return done(err); - - assert(res.contents.toString() === 'a HALLE b'); - done(); - }); - }); - - it('should use helpers when rendering a view:', function(done) { - var locals = {name: 'Halle'}; - app.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - app.page('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a HALLE b'); - done(); - }); - }); - - it('should render a template when contents is a buffer:', function(done) { - app.pages('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = app.pages.getView('a.tmpl'); - - app.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a template when content is a string:', function(done) { - app.pages('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = app.pages.getView('a.tmpl'); - - app.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/app.renderFile.js b/vendors/update/test/app.renderFile.js deleted file mode 100644 index 4e3041a1..00000000 --- a/vendors/update/test/app.renderFile.js +++ /dev/null @@ -1,135 +0,0 @@ -'use strict'; - -var assemble = require('..'); -var assert = require('assert'); -var should = require('should'); -var path = require('path'); -var app; - -describe('app.renderFile()', function() { - beforeEach(function() { - app = assemble(); - app.engine('hbs', require('engine-handlebars')); - app.engine('*', require('engine-base')); - - app.create('files', {engine: '*'}); - app.file('a', {content: 'this is <%= title() %>'}); - app.file('b', {content: 'this is <%= title() %>'}); - app.file('c', {content: 'this is <%= title() %>'}); - - app.option('renameKey', function(key) { - return path.basename(key, path.extname(key)); - }); - - app.helper('title', function() { - var view = this.context.view; - var key = view.key; - var ctx = this.context[key]; - if (ctx && ctx.title) return ctx.title; - return key; - }); - }); - - it('should render views from src', function(done) { - var stream = app.src(path.join(__dirname, 'fixtures/pages/*.hbs')); - var files = []; - - stream.pipe(app.renderFile()) - .on('error', done) - .on('data', function(file) { - files.push(file); - }) - .on('end', function() { - assert.equal(files[0].basename, 'a.hbs'); - assert.equal(files[1].basename, 'b.hbs'); - assert.equal(files[2].basename, 'c.hbs'); - done(); - }); - }); - - it('should render views with the engine that matches the file extension', function(done) { - var stream = app.src(path.join(__dirname, 'fixtures/pages/*.hbs')); - var files = []; - - stream.pipe(app.renderFile()) - .on('error', done) - .on('data', function(file) { - files.push(file); - }) - .on('end', function() { - assert(/

a<\/h1>/.test(files[0].content)); - assert(/

b<\/h1>/.test(files[1].content)); - assert(/

c<\/h1>/.test(files[2].content)); - done(); - }); - }); - - it('should render views from src with the engine passed on the opts', function(done) { - var stream = app.src(path.join(__dirname, 'fixtures/pages/*.hbs')); - var files = []; - - stream.pipe(app.renderFile({engine: '*'})) - .on('error', done) - .on('data', function(file) { - files.push(file); - }) - .on('end', function() { - assert(/

a<\/h2>/.test(files[0].content)); - assert(/

b<\/h2>/.test(files[1].content)); - assert(/

c<\/h2>/.test(files[2].content)); - done(); - }); - }); - - it('should use the context passed on the opts', function(done) { - var stream = app.src(path.join(__dirname, 'fixtures/pages/*.hbs')); - var files = []; - - stream.pipe(app.renderFile({a: {title: 'foo'}})) - .on('error', done) - .on('data', function(file) { - files.push(file); - }) - .on('end', function() { - assert(/

foo<\/h1>/.test(files[0].content)); - assert(/

b<\/h1>/.test(files[1].content)); - assert(/

c<\/h1>/.test(files[2].content)); - done(); - }); - }); - - it('should render the files in a collection', function(cb) { - var files = []; - app.toStream('files') - .pipe(app.renderFile()) - .on('error', cb) - .on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - files.push(file); - }) - .on('end', function() { - assert(/this is a/.test(files[0].content)); - assert(/this is b/.test(files[1].content)); - assert(/this is c/.test(files[2].content)); - assert.equal(files.length, 3); - cb(); - }); - }); - - it('should handle engine errors', function(cb) { - app.create('notdefined', {engine: '*'}); - app.notdefined('foo', {content: '<%= bar %>'}); - app.toStream('notdefined') - .pipe(app.renderFile()) - .on('error', function(err) { - assert.equal(typeof err, 'object'); - assert.equal(err.message, 'bar is not defined'); - cb(); - }) - .on('end', function() { - cb(new Error('expected renderFile to handle the error.')); - }); - }); -}); diff --git a/vendors/update/test/app.route.js b/vendors/update/test/app.route.js deleted file mode 100644 index 213dd56d..00000000 --- a/vendors/update/test/app.route.js +++ /dev/null @@ -1,93 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('routes', function() { - beforeEach(function() { - app = new App(); - }); - - describe('routes', function() { - it('should create a route for the given path:', function(done) { - app = new App(); - app.create('posts'); - - app.on('all', function(msg) { - assert(msg === 'done'); - done(); - }); - - app.route('blog/:title') - .all(function(view, next) { - app.emit('all', 'done'); - next(); - }); - - app.post('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - - it('should emit events when a route method is called:', function(done) { - app = new App(); - app.create('posts'); - - app.on('onLoad', function(view) { - assert(view.path === 'blog/foo.js'); - done(); - }); - - app.param('title', function(view, next, title) { - assert(title === 'foo.js'); - next(); - }); - - app.onLoad('blog/:title', function(view, next) { - assert(view.path === 'blog/foo.js'); - next(); - }); - - app.post('whatever', {path: 'blog/foo.js', content: 'bar baz'}); - }); - - it('should emit errors', function(done) { - app = new App(); - app.create('posts'); - - app.on('error', function(err) { - assert(err.message === 'false == true'); - done(); - }); - - // wrong... - app.param('title', function(view, next, title) { - assert(title === 'fo.js'); - next(); - }); - - app.onLoad('/blog/:title', function(view, next) { - assert(view.path === '/blog/foo.js'); - next(); - }); - - app.post('whatever', {path: '/blog/foo.js', content: 'bar baz'}); - }); - - it('should have path property', function() { - var route = new app.Route('/blog/:year/:month/:day/:slug').all([ - function() {} - ]); - route.path.should.equal('/blog/:year/:month/:day/:slug'); - }); - - it('should have stack property', function() { - var route = new app.Route('/blog/:year/:month/:day/:slug').all([ - function() {} - ]); - - route.stack.should.be.instanceof(Array); - route.stack.should.have.length(1); - }); - }); -}); diff --git a/vendors/update/test/app.src.js b/vendors/update/test/app.src.js deleted file mode 100644 index 034917b9..00000000 --- a/vendors/update/test/app.src.js +++ /dev/null @@ -1,295 +0,0 @@ -'use strict'; - -var App = require('..'); -var assert = require('assert'); -var should = require('should'); -var join = require('path').join; -var app; - -describe('src()', function() { - beforeEach(function() { - app = new App(); - }); - - it('should return a stream', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee')); - assert(stream); - assert.equal(typeof stream.on, 'function'); - assert.equal(typeof stream.pipe, 'function'); - done(); - }); - - it('should return an input stream from a flat glob', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee')); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - String(file.contents).should.equal('Hello world!'); - }); - stream.on('end', function() { - done(); - }); - }); - - it('should return an input stream for multiple globs', function(done) { - var globArray = [ - join(__dirname, './fixtures/generic/run.dmc'), - join(__dirname, './fixtures/generic/test.dmc') - ]; - var stream = app.src(globArray); - - var files = []; - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - files.push(file); - }); - stream.on('end', function() { - files.length.should.equal(2); - files[0].path.should.equal(globArray[0]); - files[1].path.should.equal(globArray[1]); - done(); - }); - }); - - it('should return an input stream for multiple globs with negation', function(done) { - var expectedPath = join(__dirname, './fixtures/generic/run.dmc'); - var globArray = [ - join(__dirname, './fixtures/generic/*.dmc'), - '!' + join(__dirname, './fixtures/generic/test.dmc'), - ]; - var stream = app.src(globArray); - - var files = []; - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - files.push(file); - }); - stream.on('end', function() { - files.length.should.equal(1); - files[0].path.should.equal(expectedPath); - done(); - }); - }); - - it('should return an input stream with no contents when read is false', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee'), {read: false}); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.not.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - }); - stream.on('end', function() { - done(); - }); - }); - - it('should return an input stream with contents as stream when buffer is false', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee'), {buffer: false}); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - var buf = ''; - file.contents.on('data', function(d) { - buf += d; - }); - file.contents.on('end', function() { - buf.should.equal('Hello world!'); - done(); - }); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - }); - }); - - it('should return an input stream from a deep glob', function(done) { - var stream = app.src(join(__dirname, './fixtures/**/*.jade')); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test/run.jade')); - String(file.contents).should.equal('test template'); - }); - stream.on('end', function() { - done(); - }); - }); - - it('should return an input stream from a deeper glob', function(done) { - var stream = app.src(join(__dirname, './fixtures/**/*.dmc')); - var a = 0; - stream.on('error', done); - stream.on('data', function() { - ++a; - }); - stream.on('end', function() { - a.should.equal(2); - done(); - }); - }); - - it('should return a file stream from a flat path', function(done) { - var a = 0; - var stream = app.src(join(__dirname, './fixtures/test.coffee')); - stream.on('error', done); - stream.on('data', function(file) { - ++a; - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - String(file.contents).should.equal('Hello world!'); - }); - stream.on('end', function() { - a.should.equal(1); - done(); - }); - }); - - it('should return a stream', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee')); - should.exist(stream); - should.exist(stream.on); - done(); - }); - - it('should return an input stream from a flat glob', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee')); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - String(file.contents).should.equal('Hello world!'); - }); - stream.on('end', function() { - done(); - }); - }); - - it('should return an input stream for multiple globs', function(done) { - var globArray = [ - join(__dirname, './fixtures/generic/run.dmc'), - join(__dirname, './fixtures/generic/test.dmc') - ]; - var stream = app.src(globArray); - - var files = []; - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - files.push(file); - }); - stream.on('end', function() { - files.length.should.equal(2); - files[0].path.should.equal(globArray[0]); - files[1].path.should.equal(globArray[1]); - done(); - }); - }); - - it('should return an input stream for multiple globs, with negation', function(done) { - var expectedPath = join(__dirname, './fixtures/generic/run.dmc'); - var globArray = [ - join(__dirname, './fixtures/generic/*.dmc'), - '!' + join(__dirname, './fixtures/generic/test.dmc'), - ]; - var stream = app.src(globArray); - - var files = []; - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - files.push(file); - }); - stream.on('end', function() { - files.length.should.equal(1); - files[0].path.should.equal(expectedPath); - done(); - }); - }); - - it('should return an input stream with no contents when read is false', function(done) { - var stream = app.src(join(__dirname, './fixtures/*.coffee'), {read: false}); - stream.on('error', done); - stream.on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.not.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - }); - stream.on('end', function() { - done(); - }); - }); - - it.skip('should throw an error when buffer is false', function(done) { - app.src(join(__dirname, './fixtures/*.coffee'), {buffer: false}) - .on('error', function() { - done(); - }) - .on('data', function() { - done(new Error('should have thrown an error')); - }); - }); - - it('should return an input stream from a deep glob', function(done) { - app.src(join(__dirname, './fixtures/**/*.jade')) - .on('error', done) - .on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test/run.jade')); - String(file.contents).should.equal('test template'); - }) - .on('end', function() { - done(); - }); - }); - - it('should return an input stream from a deeper glob', function(done) { - var stream = app.src(join(__dirname, './fixtures/**/*.dmc')); - var a = 0; - stream.on('error', done); - stream.on('data', function() { - ++a; - }); - stream.on('end', function() { - a.should.equal(2); - done(); - }); - }); - - it('should return a file stream from a flat path', function(done) { - var a = 0; - var stream = app.src(join(__dirname, './fixtures/test.coffee')); - stream.on('error', done); - stream.on('data', function(file) { - ++a; - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - join(file.path, '').should.equal(join(__dirname, './fixtures/test.coffee')); - String(file.contents).should.equal('Hello world!'); - }); - stream.on('end', function() { - a.should.equal(1); - done(); - }); - }); -}); diff --git a/vendors/update/test/app.symlink.js b/vendors/update/test/app.symlink.js deleted file mode 100644 index 69e8d459..00000000 --- a/vendors/update/test/app.symlink.js +++ /dev/null @@ -1,396 +0,0 @@ -require('mocha'); -var should = require('should'); -var fs = require('graceful-fs'); -var path = require('path'); -var rimraf = require('rimraf'); -var bufEqual = require('buffer-equal'); -var through = require('through2'); -var File = require('vinyl'); -var assemble = require('..'); -var spies = require('./support/spy'); -var chmodSpy = spies.chmodSpy; -var statSpy = spies.statSpy; -var app, bufferStream; - -var wipeOut = function(cb) { - rimraf(path.join(__dirname, './actual/'), cb); - spies.setError('false'); - statSpy.reset(); - chmodSpy.reset(); - app = assemble(); -}; - -var dataWrap = function(fn) { - return function(data, enc, cb) { - fn(data); - cb(); - }; -}; - -var realMode = function(n) { - return n & 07777; -}; - -describe('symlink stream', function() { - beforeEach(wipeOut); - afterEach(wipeOut); - - it('should pass through writes with cwd', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - - var expectedFile = new File({ - base: __dirname, - cwd: __dirname, - path: inputPath, - contents: null - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - done(); - }; - - var stream = app.symlink('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should pass through writes with default cwd', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - - var expectedFile = new File({ - base: __dirname, - cwd: __dirname, - path: inputPath, - contents: null - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - done(); - }; - - var stream = app.symlink(path.join(__dirname, './actual/')); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should make link to the right folder with relative cwd', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedPath = path.join(__dirname, './actual/test.coffee'); - var expectedBase = path.join(__dirname, './actual'); - var expectedContents = fs.readFileSync(inputPath); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - fs.readlinkSync(expectedPath).should.equal(inputPath); - done(); - }; - - var stream = app.symlink('./actual/', {cwd: path.relative(process.cwd(), __dirname)}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write buffer files to the right folder with function and relative cwd', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedPath = path.join(__dirname, './actual/test.coffee'); - var expectedBase = path.join(__dirname, './actual'); - var expectedContents = fs.readFileSync(inputPath); - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - fs.readlinkSync(expectedPath).should.equal(inputPath); - done(); - }; - - var stream = app.symlink(function(file){ - should.exist(file); - file.should.equal(expectedFile); - return './actual'; - }, {cwd: path.relative(process.cwd(), __dirname)}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write buffer files to the right folder', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedPath = path.join(__dirname, './actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, './actual'); - var expectedMode = 0655; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - fs.readlinkSync(expectedPath).should.equal(inputPath); - done(); - }; - - var stream = app.symlink('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should write streaming files to the right folder', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedPath = path.join(__dirname, './actual/test.coffee'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, './actual'); - var expectedMode = 0655; - - var contentStream = through.obj(); - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: contentStream, - stat: { - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.existsSync(expectedPath).should.equal(true); - bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); - fs.readlinkSync(expectedPath).should.equal(inputPath); - done(); - }; - - var stream = app.symlink('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - setTimeout(function(){ - contentStream.write(expectedContents); - contentStream.end(); - }, 100); - stream.end(); - }); - - it('should write directories to the right folder', function(done) { - var inputPath = path.join(__dirname, './fixtures/wow'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedPath = path.join(__dirname, './actual/wow'); - var expectedBase = path.join(__dirname, './actual'); - var expectedMode = 0655; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: null, - stat: { - isDirectory: function(){ - return true; - }, - mode: expectedMode - } - }); - - var onEnd = function(){ - buffered.length.should.equal(1); - buffered[0].should.equal(expectedFile); - buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); - buffered[0].base.should.equal(expectedBase, 'base should have changed'); - buffered[0].path.should.equal(expectedPath, 'path should have changed'); - fs.readlinkSync(expectedPath).should.equal(inputPath); - fs.lstatSync(expectedPath).isDirectory().should.equal(false); - fs.statSync(expectedPath).isDirectory().should.equal(true); - done(); - }; - - var stream = app.symlink('./actual/', {cwd: __dirname}); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - stream.pipe(bufferStream); - stream.write(expectedFile); - stream.end(); - }); - - it('should use different modes for files and directories', function(done) { - var inputBase = path.join(__dirname, './fixtures'); - var inputPath = path.join(__dirname, './fixtures/wow/suchempty'); - var expectedBase = path.join(__dirname, './actual/wow'); - var expectedDirMode = 0755; - var expectedFileMode = 0655; - - var firstFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - stat: fs.statSync(inputPath) - }); - - var onEnd = function(){ - realMode(fs.lstatSync(expectedBase).mode).should.equal(expectedDirMode); - realMode(buffered[0].stat.mode).should.equal(expectedFileMode); - done(); - }; - - var stream = app.symlink('./actual/', { - cwd: __dirname, - mode: expectedFileMode, - dirMode: expectedDirMode - }); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(firstFile); - stream.end(); - }); - - it('should change to the specified base', function(done) { - var inputBase = path.join(__dirname, './fixtures'); - var inputPath = path.join(__dirname, './fixtures/wow/suchempty'); - - var firstFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - stat: fs.statSync(inputPath) - }); - - var onEnd = function(){ - buffered[0].base.should.equal(inputBase); - done(); - }; - - var stream = app.symlink('./actual/', { - cwd: __dirname, - base: inputBase - }); - - var buffered = []; - bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); - - stream.pipe(bufferStream); - stream.write(firstFile); - stream.end(); - }); - - it('should report IO errors', function(done) { - var inputPath = path.join(__dirname, './fixtures/test.coffee'); - var inputBase = path.join(__dirname, './fixtures/'); - var expectedContents = fs.readFileSync(inputPath); - var expectedBase = path.join(__dirname, './actual'); - var expectedMode = 0722; - - var expectedFile = new File({ - base: inputBase, - cwd: __dirname, - path: inputPath, - contents: expectedContents, - stat: { - mode: expectedMode - } - }); - - fs.mkdirSync(expectedBase); - fs.chmodSync(expectedBase, 0); - - var stream = app.symlink('./actual/', {cwd: __dirname}); - stream.on('error', function(err) { - err.code.should.equal('EACCES'); - done(); - }); - stream.write(expectedFile); - }); - - ['end', 'finish'].forEach(function(eventName) { - it('should emit ' + eventName + ' event', function(done) { - var srcPath = path.join(__dirname, './fixtures/test.coffee'); - var stream = app.symlink('./actual/', {cwd: __dirname}); - - stream.on(eventName, function() { - done(); - }); - - var file = new File({ - path: srcPath, - cwd: __dirname, - contents: new Buffer("1234567890") - }); - - stream.write(file); - stream.end(); - }); - }); -}); diff --git a/vendors/update/test/app.task.js b/vendors/update/test/app.task.js deleted file mode 100644 index 333f4fdc..00000000 --- a/vendors/update/test/app.task.js +++ /dev/null @@ -1,159 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var App = require('..'); -var app; - -describe('task()', function() { - beforeEach(function() { - app = new App(); - app.tasks = {}; - }); - - it('should register a task', function() { - var fn = function(done) { - done(); - }; - app.task('default', fn); - assert.equal(typeof app.tasks.default, 'object'); - assert.equal(app.tasks.default.fn, fn); - }); - - it('should register a task with an array of dependencies', function() { - app.task('default', ['foo', 'bar'], function(done) { - done(); - }); - assert.equal(typeof app.tasks.default, 'object'); - assert.deepEqual(app.tasks.default.deps, ['foo', 'bar']); - }); - - it('should register a task with a list of strings as dependencies', function() { - app.task('default', 'foo', 'bar', function(done) { - done(); - }); - assert.equal(typeof app.tasks.default, 'object'); - assert.deepEqual(app.tasks.default.deps, ['foo', 'bar']); - }); - - it('should run a task', function(done) { - var count = 0; - app.task('default', function(cb) { - count++; - cb(); - }); - - app.build('default', function(err) { - if (err) return done(err); - assert.equal(count, 1); - done(); - }); - }); - - it('should throw an error when a task with unregistered dependencies is run', function(done) { - var count = 0; - app.task('default', ['foo', 'bar'], function(cb) { - count++; - cb(); - }); - - app.build('default', function(err) { - if (!err) return done(new Error('Expected an error to be thrown.')); - assert.equal(count, 0); - done(); - }); - }); - - it('should throw an error when `.build` is called without a callback function.', function() { - try { - app.build('default'); - throw new Error('Expected an error to be thrown.'); - } catch (err) { - } - }); - - it('should emit task events', function(done) { - var events = []; - app.on('task:starting', function(task) { - events.push('starting.' + task.name); - }); - app.on('task:finished', function(task) { - events.push('finished.' + task.name); - }); - app.on('task:error', function(err, task) { - events.push('error.' + task.name); - }); - - app.task('foo', function(cb) { - cb(); - }); - app.task('bar', ['foo'], function(cb) { - cb(); - }); - app.task('default', ['bar']); - app.build('default', function(err) { - if (err) return done(err); - assert.deepEqual(events, [ - 'starting.default', - 'starting.bar', - 'starting.foo', - 'finished.foo', - 'finished.bar', - 'finished.default' - ]); - done(); - }); - }); - - it('should emit an error event when an error is passed back in a task', function(done) { - app.on('error', function(err) { - assert(err); - assert.equal(err.message, 'This is an error'); - }); - app.task('default', function(cb) { - return cb(new Error('This is an error')); - }); - app.build('default', function(err) { - if (err) return done(); - done(new Error('Expected an error')); - }); - }); - - it('should emit an error event when an error is thrown in a task', function(done) { - var errors = 0; - app.on('error', function(err) { - errors++; - assert(err); - assert.equal(err.message, 'This is an error'); - }); - app.task('default', function(cb) { - cb(new Error('This is an error')); - }); - app.build('default', function(err) { - assert.equal(errors, 1); - if (err) return done(); - done(new Error('Expected an error')); - }); - }); - - it('should run dependencies before running the dependent task.', function(done) { - var seq = []; - app.task('foo', function(cb) { - seq.push('foo'); - cb(); - }); - app.task('bar', function(cb) { - seq.push('bar'); - cb(); - }); - app.task('default', ['foo', 'bar'], function(cb) { - seq.push('default'); - cb(); - }); - - app.build('default', function(err) { - if (err) return done(err); - assert.deepEqual(seq, ['foo', 'bar', 'default']); - done(); - }); - }); -}); diff --git a/vendors/update/test/app.toStream.js b/vendors/update/test/app.toStream.js deleted file mode 100644 index fddfb93c..00000000 --- a/vendors/update/test/app.toStream.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var assemble = require('..'); -var assert = require('assert'); -var should = require('should'); -var app; - -describe('toStream()', function() { - beforeEach(function() { - app = assemble(); - app.create('pages'); - app.page('a', {content: 'this is A'}); - app.page('b', {content: 'this is B'}); - app.page('c', {content: 'this is C'}); - - app.create('posts'); - app.post('x', {content: 'this is X'}); - app.post('y', {content: 'this is Y'}); - app.post('z', {content: 'this is Z'}); - }); - - it('should return a stream', function(cb) { - var stream = app.toStream(); - should.exist(stream); - should.exist(stream.on); - cb(); - }); - - it('should return a stream for a collection', function(cb) { - var stream = app.toStream('pages'); - should.exist(stream); - should.exist(stream.on); - cb(); - }); - - it('should stack handle multiple collections', function(cb) { - var files = []; - app.toStream('pages') - .pipe(app.toStream('posts')) - .on('data', function(file) { - files.push(file); - }) - .on('end', function() { - assert.equal(files.length, 6); - cb(); - }); - }); - - it('should push each item in the collection into the stream', function(cb) { - var files = []; - app.toStream('pages') - .on('error', cb) - .on('data', function(file) { - should.exist(file); - should.exist(file.path); - should.exist(file.contents); - files.push(file.path); - }) - .on('end', function() { - assert.equal(files.length, 3); - cb(); - }); - }); -}); \ No newline at end of file diff --git a/vendors/update/test/app.use.js b/vendors/update/test/app.use.js deleted file mode 100644 index 6ca99acd..00000000 --- a/vendors/update/test/app.use.js +++ /dev/null @@ -1,281 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Views = App.Views; -var View = App.View; -var app; - -describe('app.use', function() { - beforeEach(function() { - app = new App(); - }); - - it('should expose the instance to `use`:', function(done) { - app.use(function(inst) { - assert(inst instanceof App); - done(); - }); - }); - - it('should be chainable:', function(done) { - app.use(function(inst) { - assert(inst instanceof App); - }) - .use(function(inst) { - assert(inst instanceof App); - }) - .use(function(inst) { - assert(inst instanceof App); - done(); - }); - }); - - it('should pass to collection `use` if a function is returned:', function() { - app.use(function(inst) { - assert(inst instanceof App); - return function(collection) { - collection.foo = collection.addView; - assert(collection instanceof Views); - return collection; - }; - }); - - app.create('pages') - .foo({path: 'a.md', content: '...'}) - .addView({path: 'b.md', content: '...'}) - .addView({path: 'c.md', content: '...'}); - - assert(app.views.pages.hasOwnProperty('a.md')); - assert(app.views.pages.hasOwnProperty('b.md')); - assert(app.views.pages.hasOwnProperty('c.md')); - }); - - it('should be chainable when a collection function is returned:', function() { - app - .use(function(inst) { - assert(inst instanceof App); - return function(collection) { - collection.foo = collection.addView; - assert(collection instanceof Views); - return collection; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - return function(collection) { - collection.bar = collection.addView; - assert(collection instanceof Views); - return collection; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - return function(collection) { - collection.baz = collection.addView; - assert(collection instanceof Views); - return collection; - }; - }); - - var pages = app.create('pages'); - - pages.foo({path: 'a.md', content: '...'}); - pages.bar({path: 'b.md', content: '...'}); - pages.baz({path: 'c.md', content: '...'}); - - assert(app.views.pages.hasOwnProperty('a.md')); - assert(app.views.pages.hasOwnProperty('b.md')); - assert(app.views.pages.hasOwnProperty('c.md')); - }); - - it('should pass to view `use` if collection.use returns a function:', function() { - app.use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.foo = collection.addView; - - return function(view) { - assert(view instanceof View); - view.foo = collection.addView.bind(collection); - return view; - }; - }; - }); - - app.create('pages') - .foo({path: 'a.md', content: '...'}) - .foo({path: 'b.md', content: '...'}) - .foo({path: 'c.md', content: '...'}); - - assert(app.views.pages.hasOwnProperty('a.md')); - assert(app.views.pages.hasOwnProperty('b.md')); - assert(app.views.pages.hasOwnProperty('c.md')); - }); - - it('should be chainable when a view function is returned:', function() { - app - .use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.foo = collection.addView; - - return function(view) { - assert(view instanceof View); - view.a = collection.addView.bind(collection); - return view; - }; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.bar = collection.addView; - - return function(view) { - assert(view instanceof View); - view.b = collection.addView.bind(collection); - return view; - }; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.baz = collection.addView; - - return function(view) { - assert(view instanceof View); - view.c = collection.addView.bind(collection); - return view; - }; - }; - }); - - var pages = app.create('pages'); - - pages.foo({path: 'a.md', content: '...'}); - pages.bar({path: 'b.md', content: '...'}); - pages.baz({path: 'c.md', content: '...'}) - .a({path: 'x.md', content: '...'}) - .b({path: 'y.md', content: '...'}) - .c({path: 'z.md', content: '...'}); - - assert(app.views.pages.hasOwnProperty('a.md')); - assert(app.views.pages.hasOwnProperty('b.md')); - assert(app.views.pages.hasOwnProperty('c.md')); - - assert(app.views.pages.hasOwnProperty('x.md')); - assert(app.views.pages.hasOwnProperty('y.md')); - assert(app.views.pages.hasOwnProperty('z.md')); - }); - - it('should work with multiple collections:', function() { - app - .use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.foo = collection.addView; - - return function(view) { - assert(view instanceof View); - view.a = collection.addView.bind(collection); - return view; - }; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - - return function(collection) { - assert(collection instanceof Views); - collection.bar = collection.addView; - - return function(view) { - assert(view instanceof View); - view.b = collection.addView.bind(collection); - return view; - }; - }; - }) - .use(function(inst) { - assert(inst instanceof App); - assert(this instanceof App); - - return function(collection) { - collection.baz = collection.addView; - assert(collection instanceof Views); - assert(this instanceof Views); - - return function(view) { - assert(this instanceof View); - assert(view instanceof View); - view.c = collection.addView.bind(collection); - return view; - }; - }; - }); - - var pages = app.create('pages'); - - pages.foo({path: 'a.md', content: '...'}); - pages.bar({path: 'b.md', content: '...'}); - pages.baz({path: 'c.md', content: '...'}) - .a({path: 'x.md', content: '...'}) - .b({path: 'y.md', content: '...'}) - .c({path: 'z.md', content: '...'}); - - assert(app.views.pages.hasOwnProperty('a.md')); - assert(app.views.pages.hasOwnProperty('b.md')); - assert(app.views.pages.hasOwnProperty('c.md')); - - assert(app.views.pages.hasOwnProperty('x.md')); - assert(app.views.pages.hasOwnProperty('y.md')); - assert(app.views.pages.hasOwnProperty('z.md')); - - var posts = app.create('posts'); - - posts.foo({path: 'a.md', content: '...'}); - posts.bar({path: 'b.md', content: '...'}); - posts.baz({path: 'c.md', content: '...'}) - .a({path: 'x.md', content: '...'}) - .b({path: 'y.md', content: '...'}) - .c({path: 'z.md', content: '...'}); - - assert(app.views.posts.hasOwnProperty('a.md')); - assert(app.views.posts.hasOwnProperty('b.md')); - assert(app.views.posts.hasOwnProperty('c.md')); - - assert(app.views.posts.hasOwnProperty('x.md')); - assert(app.views.posts.hasOwnProperty('y.md')); - assert(app.views.posts.hasOwnProperty('z.md')); - - var docs = app.create('docs'); - - docs.foo({path: 'a.md', content: '...'}); - docs.bar({path: 'b.md', content: '...'}); - docs.baz({path: 'c.md', content: '...'}) - .a({path: 'x.md', content: '...'}) - .b({path: 'y.md', content: '...'}) - .c({path: 'z.md', content: '...'}); - - assert(app.views.docs.hasOwnProperty('a.md')); - assert(app.views.docs.hasOwnProperty('b.md')); - assert(app.views.docs.hasOwnProperty('c.md')); - - assert(app.views.docs.hasOwnProperty('x.md')); - assert(app.views.docs.hasOwnProperty('y.md')); - assert(app.views.docs.hasOwnProperty('z.md')); - }); -}); diff --git a/vendors/update/test/app.view.compile.js b/vendors/update/test/app.view.compile.js deleted file mode 100644 index 4dca5cdd..00000000 --- a/vendors/update/test/app.view.compile.js +++ /dev/null @@ -1,38 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('app.view.compile', function() { - describe('compile method', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - it('should compile a view:', function() { - var buffer = new Buffer('a b c'); - var view = app.page('a.tmpl', {contents: buffer}) - .compile(); - assert(typeof view.fn === 'function'); - }); - - it('should compile a view with settings:', function() { - var buffer = new Buffer('a b c'); - var view = app.page('a.tmpl', {contents: buffer}) - .compile({foo: 'bar'}); - assert(typeof view.fn === 'function'); - }); - - it('should compile a view with isAsync flag:', function() { - var buffer = new Buffer('a b c'); - var view = app.page('a.tmpl', {contents: buffer}) - .compile(true); - assert(typeof view.fn === 'function'); - }); - }); -}); - diff --git a/vendors/update/test/app.view.render.js b/vendors/update/test/app.view.render.js deleted file mode 100644 index 1cfd929c..00000000 --- a/vendors/update/test/app.view.render.js +++ /dev/null @@ -1,92 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('helpers', function() { - describe('rendering', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - it('should use helpers to render a view:', function(done) { - var locals = {name: 'Halle'}; - - app.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - var buffer = new Buffer('a <%= upper(name) %> b'); - app.page('a.tmpl', {contents: buffer, locals: locals}) - .render(function(err, res) { - if (err) return done(err); - - assert(res.contents.toString() === 'a HALLE b'); - done(); - }); - }); - - it('should support helpers as an array:', function(done) { - var locals = {name: 'Halle'}; - - app.helpers([ - { - lower: function(str) { - return str.toLowerCase(str); - } - } - ]); - - var buffer = new Buffer('a <%= lower(name) %> b'); - app.page('a.tmpl', {contents: buffer, locals: locals}) - .render(function(err, res) { - if (err) return done(err); - - assert(res.contents.toString() === 'a halle b'); - done(); - }); - }); - - it('should support helpers as an object:', function(done) { - var locals = {name: 'Halle'}; - - app.helpers({ - prepend: function(prefix, str) { - return prefix + str; - } - }); - - var buffer = new Buffer('a <%= prepend("foo ", name) %> b'); - app.page('a.tmpl', {contents: buffer, locals: locals}) - .render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a foo Halle b'); - done(); - }); - }); - - it('should use the engine defined on view options:', function(done) { - app.engine('hbs', require('engine-handlebars')); - var locals = {name: 'Halle'}; - - app.helpers({ - prepend: function(prefix, str) { - return prefix + str; - } - }); - - var buffer = new Buffer('a {{prepend "foo " name}} b'); - app.page('a.tmpl', {contents: buffer, locals: locals, options: {engine: 'hbs'}}) - .render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a foo Halle b'); - done(); - }); - }); - }); -}); - diff --git a/vendors/update/test/app.watch.js b/vendors/update/test/app.watch.js deleted file mode 100644 index 0990e70e..00000000 --- a/vendors/update/test/app.watch.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var fs = require('fs'); -var App = require('..'); -var app; - -describe.skip('watch()', function() { - beforeEach(function() { - app = new App({runtimes: false}); - }); - - it('should watch files and run a task when files change', function(done) { - this.timeout(750); - - var count = 0, watch; - app.task('default', function(cb) { - count++; - cb(); - }); - - app.task('close', function(cb) { - watch.close(); - app.emit('close'); - cb(); - }); - - app.task('watch', function(cb) { - watch = app.watch('test/fixtures/watch/*.txt', ['default', 'close']); - fs.writeFile('test/fixtures/watch/test.txt', 'test', function(err) { - if (err) return cb(err); - app.on('close', cb); - }); - }); - - app.build(['watch'], function(err) { - if (err) return done(err); - assert.equal(count, 1); - done(); - }); - }); -}); diff --git a/vendors/update/test/collection.engines.js b/vendors/update/test/collection.engines.js deleted file mode 100644 index 3465c9e5..00000000 --- a/vendors/update/test/collection.engines.js +++ /dev/null @@ -1,176 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Views = App.Views; -var collection, pages; - -describe('collection engines', function() { - beforeEach(function() { - pages = new Views(); - }); - - it('should throw an error when engine name is invalid:', function() { - (function() { - pages.engine(null, {}); - }).should.throw('expected engine ext to be a string or array.'); - }); - - it('should register an engine to the given extension', function() { - pages.engine('hbs', function() {}); - assert(typeof pages.engines['.hbs'] === 'object'); - }); - - it('should set an engine with the given extension', function() { - var hbs = function() {}; - hbs.render = function() {}; - hbs.renderFile = function() {}; - pages.engine('hbs', hbs); - assert(pages.engines['.hbs']); - assert(pages.engines['.hbs'].renderFile); - assert(pages.engines['.hbs'].render); - }); - - it('should get an engine:', function() { - pages.engine('hbs', function() {}); - var hbs = pages.engine('hbs'); - assert(typeof hbs === 'object'); - assert(hbs.hasOwnProperty('render')); - assert(hbs.hasOwnProperty('compile')); - }); - - it('should register multiple engines to the given extension', function() { - pages.engine(['hbs', 'md'], function() {}); - assert(typeof pages.engines['.hbs'] === 'object'); - assert(typeof pages.engines['.md'] === 'object'); - }); -}); - -describe('engines', function() { - beforeEach(function() { - pages = new Views(); - pages.addView('foo.tmpl', {content: 'A <%= letter %> {{= letter }} C'}); - pages.addView('bar.tmpl', {content: 'A <%= letter %> {{ letter }} C'}); - }); - - it('should register an engine:', function() { - pages.engine('a', {render: function() {}}); - pages.engines.should.have.property('.a'); - }); - - it('should use custom delimiters:', function(done) { - pages.engine('tmpl', require('engine-base'), { - delims: ['{{', '}}'] - }); - - pages.render('foo.tmpl', {letter: 'B'}, function(err, res) { - if (err) return done(err); - res.content.should.equal('A <%= letter %> B C'); - done(); - }); - }); - - it('should override individual delims values:', function(done) { - pages.engine('tmpl', require('engine-base'), { - interpolate: /\{{([^}]+)}}/g, - evaluate: /\{{([^}]+)}}/g, - escape: /\{{-([^}]+)}}/g - }); - pages.render('bar.tmpl', {letter: 'B'}, function(err, res) { - if (err) return done(err); - res.content.should.equal('A <%= letter %> B C'); - done(); - }); - }); - - it('should get an engine:', function() { - pages.engine('a', { - render: function() {} - }); - var a = pages.engine('a'); - a.should.have.property('render'); - }); -}); - -describe('engine selection:', function() { - beforeEach(function(done) { - collection = new Views(); - collection.engine('tmpl', require('engine-base')); - collection.engine('hbs', require('engine-handlebars')); - done(); - }); - - it('should get the engine from file extension:', function(done) { - var pages = new Views(); - pages.engine('tmpl', require('engine-base')); - pages.engine('hbs', require('engine-handlebars')); - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use the engine defined on the collection:', function(done) { - var posts = new Views({engine: 'hbs'}); - posts.engine('tmpl', require('engine-base')); - posts.engine('hbs', require('engine-handlebars')); - - posts.addView('a', {content: '{{a}}', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use the engine defined on the view:', function(done) { - var posts = new Views(); - posts.engine('tmpl', require('engine-base')); - posts.engine('hbs', require('engine-handlebars')); - posts.addView('a', {content: '{{a}}', engine: 'hbs', locals: {a: 'b'}}) - .render(function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use the engine defined on view.options:', function(done) { - var posts = new Views(); - posts.engine('tmpl', require('engine-base')); - posts.engine('hbs', require('engine-handlebars')); - posts.addView('a', {content: '{{a}}', data: {a: 'b'}, options: {engine: 'hbs'}}) - .render(function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use the engine defined on view.data:', function(done) { - var posts = new Views(); - posts.engine('tmpl', require('engine-base')); - posts.engine('hbs', require('engine-handlebars')); - posts.addView('a', {content: '{{a}}', locals: {a: 'b'}, data: {engine: 'hbs'}}) - .render(function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use the engine defined on render locals:', function(done) { - var posts = new Views(); - posts.engine('tmpl', require('engine-base')); - posts.engine('hbs', require('engine-handlebars')); - posts.addView('a', {content: '{{a}}', locals: {a: 'b'}}) - .render({engine: 'hbs'}, function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); -}); diff --git a/vendors/update/test/collection.events.js b/vendors/update/test/collection.events.js deleted file mode 100644 index bdf9eaf0..00000000 --- a/vendors/update/test/collection.events.js +++ /dev/null @@ -1,27 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('collection events', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - }); - - it('should emit events:', function() { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}); - var events = []; - - app.pages.on('option', function(key) { - events.push(key); - }); - - app.pages.option('a', 'b'); - app.pages.option('c', 'd'); - app.pages.option('e', 'f'); - app.pages.option({g: 'h'}); - - events.should.eql(['a', 'c', 'e', 'g']); - }); -}); diff --git a/vendors/update/test/collection.getView.js b/vendors/update/test/collection.getView.js deleted file mode 100644 index fb587230..00000000 --- a/vendors/update/test/collection.getView.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -var path = require('path'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('collection.getView', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - - app.page('foo', {content: 'this is foo'}); - app.page('bar.md', {content: 'this is bar'}); - app.page('a/b/c/baz.md', {content: 'this is baz'}); - app.page('test/fixtures/templates/a.tmpl'); - }); - - it('should get a view by name', function() { - assert(app.pages.getView('foo')); - }); - - it('should get a view with the key modified by the given function', function() { - var view = app.pages.getView('foo.md', function(key) { - return path.basename(key, path.extname(key)); - }); - assert(view); - }); - - it('should get a view by full path', function() { - assert(app.pages.getView('a/b/c/baz.md')); - }); -}); diff --git a/vendors/update/test/collection.js b/vendors/update/test/collection.js deleted file mode 100644 index 7c0982c4..00000000 --- a/vendors/update/test/collection.js +++ /dev/null @@ -1,540 +0,0 @@ -require('mocha'); -require('should'); -var path = require('path'); -var assert = require('assert'); -var typeOf = require('kind-of'); -var isBuffer = require('is-buffer'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var Item = App.Item; -var Collection = App.Collection; -var collection; - -describe('collection', function() { - describe('constructor', function() { - it('should create an instance of Collection', function() { - var collection = new Collection(); - assert(collection instanceof Collection); - assert(typeof collection === 'object'); - }); - - it('should instantiate without new', function() { - var collection = Collection(); - assert(collection instanceof Collection); - assert(typeof collection === 'object'); - }); - }); - - describe('static methods', function() { - it('should expose `extend`', function() { - assert(typeof Collection.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - collection = new Collection(); - }); - - var methods = [ - 'use', - 'setItem', - 'addItem', - 'addItems', - 'addList', - 'getItem', - 'constructor', - 'set', - 'get', - 'del', - 'define', - 'visit', - 'on', - 'once', - 'off', - 'emit', - 'listeners', - 'hasListeners' - ]; - - methods.forEach(function(method) { - it('should expose ' + method + ' method', function() { - assert(typeof collection[method] === 'function'); - }); - }); - - it('should expose isCollection property', function() { - assert(typeof collection.isCollection === 'boolean'); - }); - - it('should expose queue property', function() { - assert(Array.isArray(collection.queue)); - }); - - it('should expose items property', function() { - assert(typeOf(collection.items) === 'object'); - }); - - it('should expose options property', function() { - assert(typeOf(collection.options) === 'object'); - }); - }); -}); - -describe('methods', function() { - beforeEach(function() { - collection = new Collection(); - }); - - describe('chaining', function() { - it('should allow collection methods to be chained', function() { - collection - .addItems({'a.hbs': {path: 'a.hbs'}}) - .addItems({'b.hbs': {path: 'b.hbs'}}) - .addItems({'c.hbs': {path: 'c.hbs'}}); - - collection.items.should.have.properties([ - 'a.hbs', - 'b.hbs', - 'c.hbs' - ]); - }); - }); - - describe('use', function() { - it('should expose the instance to plugins', function() { - collection - .use(function(inst) { - inst.foo = 'bar'; - }); - - assert(collection.foo === 'bar'); - }); - - it('should expose `item` when the plugin returns a function', function() { - collection - .use(function() { - return function(item) { - item.foo = 'bar'; - }; - }); - - collection.addItem('aaa'); - collection.addItem('bbb'); - collection.addItem('ccc'); - - assert(collection.items.aaa.foo === 'bar'); - assert(collection.items.bbb.foo === 'bar'); - assert(collection.items.ccc.foo === 'bar'); - }); - }); - - describe('get / set', function() { - it('should set a value on the instance', function() { - collection.set('a', 'b'); - assert(collection.a === 'b'); - }); - - it('should get a value from the instance', function() { - collection.set('a', 'b'); - assert(collection.get('a') === 'b'); - }); - }); - - describe('adding items', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should load a item onto the respective collection', function() { - collection.addItem('a.hbs'); - collection.items.should.have.property('a.hbs'); - }); - }); - - describe('item', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should return a single collection item from a key-value pair', function() { - var one = collection.item('one', {content: 'foo'}); - var two = collection.item('two', {content: 'bar'}); - - assert(one instanceof Item); - assert(one instanceof collection.Item); - assert(one.path === 'one'); - assert(two instanceof Item); - assert(two instanceof collection.Item); - assert(two.path === 'two'); - }); - - it('should return a single collection item from an object', function() { - var one = collection.item({path: 'one', content: 'foo'}); - var two = collection.item({path: 'two', content: 'bar'}); - - assert(one instanceof Item); - assert(one.path === 'one'); - assert(two instanceof Item); - assert(two.path === 'two'); - }); - }); - - describe('addItem', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should throw an error when args are invalid', function() { - (function() { - collection.addItem(function() {}); - }).should.throw('expected value to be an object.'); - }); - - it('should add a item to `items`', function() { - collection.addItem('foo'); - collection.items.should.have.property('foo'); - - collection.addItem('one', {content: '...'}); - assert(typeof collection.items.one === 'object'); - assert(isBuffer(collection.items.one.contents)); - }); - - it('should create an instance of `Item`', function() { - collection.addItem('one', {content: '...'}); - assert(collection.items.one instanceof collection.Item); - }); - - it('should allow an `Item` constructor to be passed', function() { - Item.prototype.foo = function(key, value) { - this[key] = value; - }; - collection = new Collection({Item: Item}); - collection.addItem('one', {content: '...'}); - collection.items.one.foo('bar', 'baz'); - assert(collection.items.one.bar === 'baz'); - }); - - it('should allow an instance of `Item` to be passed', function() { - var collection = new Collection({Item: Item}); - var item = new Item({content: '...'}); - collection.addItem('one', item); - item.set('abc', 'xyz'); - assert(collection.items.one instanceof collection.Item); - assert(isBuffer(collection.items.one.contents)); - assert(collection.items.one.abc === 'xyz'); - }); - }); - - describe('addItems', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should add multiple items', function() { - collection.addItems({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.items.two.contents)); - }); - - it('should create items from an instance of Collection', function() { - collection.addItems({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - var pages = new Collection(collection); - assert(isBuffer(pages.items.one.contents)); - assert(isBuffer(pages.items.two.contents)); - }); - - it('should add an array of plain-objects', function() { - collection.addItems([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.items.two.contents)); - }); - - it('should add an array of items', function() { - var list = new List([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - - collection.addItems(list.items); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.items.two.contents)); - }); - }); - - describe('addList', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should add a list of items', function() { - collection.addList([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.items.two.contents)); - }); - - it('should add a list of items from the constructor', function() { - var list = new List([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - - collection = new Collection(list); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.items.two.contents)); - }); - - it('should throw an error when list is not an array', function() { - var items = new Collection(); - (function() { - items.addList(); - }).should.throw('expected list to be an array.'); - - (function() { - items.addList({}); - }).should.throw('expected list to be an array.'); - - (function() { - items.addList('foo'); - }).should.throw('expected list to be an array.'); - }); - - it('should load an array of items from an event', function() { - var collection = new Collection(); - - collection.on('addList', function(list) { - while (list.length) { - collection.addItem({path: list.pop()}); - } - }); - - collection.addList(['a.txt', 'b.txt', 'c.txt']); - assert(collection.items.hasOwnProperty('a.txt')); - assert(collection.items['a.txt'].path === 'a.txt'); - }); - - it('should load an array of items from the addList callback:', function() { - var collection = new Collection(); - - collection.addList(['a.txt', 'b.txt', 'c.txt'], function(fp) { - return {path: fp}; - }); - assert(collection.items.hasOwnProperty('a.txt')); - assert(collection.items['a.txt'].path === 'a.txt'); - }); - - it('should load an object of items from an event', function() { - var collection = new Collection(); - - collection.on('addItems', function(items) { - for (var key in items) { - collection.addItem('foo/' + key, items[key]); - delete items[key]; - } - }); - - collection.addItems({ - a: {path: 'a.txt'}, - b: {path: 'b.txt'}, - c: {path: 'c.txt'} - }); - - assert(collection.items.hasOwnProperty('foo/a')); - assert(collection.items['foo/a'].path === 'a.txt'); - }); - - it('should signal `loaded` when finished (addItems)', function() { - var collection = new Collection(); - - collection.on('addItems', function(items) { - for (var key in items) { - if (key === 'c') { - collection.loaded = true; - break; - } - collection.addItem('foo/' + key, items[key]); - } - }); - - collection.addItems({ - a: {path: 'a.txt'}, - b: {path: 'b.txt'}, - c: {path: 'c.txt'} - }); - - assert(collection.items.hasOwnProperty('foo/a')); - assert(!collection.items.hasOwnProperty('foo/c')); - assert(collection.items['foo/a'].path === 'a.txt'); - }); - - it('should signal `loaded` when finished (addList)', function() { - var collection = new Collection(); - - collection.on('addList', function(items) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (item.key === 'c') { - collection.loaded = true; - break; - } - item.key = 'foo/' + item.key; - collection.addItem(item.key, item); - } - }); - - collection.addList([ - {key: 'a', path: 'a.txt'}, - {key: 'b', path: 'b.txt'}, - {key: 'c', path: 'c.txt'} - ]); - - assert(collection.items.hasOwnProperty('foo/a')); - assert(collection.items['foo/a'].path === 'a.txt'); - assert(!collection.items.hasOwnProperty('foo/c')); - }); - }); - - describe('getItem', function() { - beforeEach(function() { - collection = new Collection(); - }); - it('should get a item from `items`', function() { - collection.addItem('one', {content: 'aaa'}); - collection.addItem('two', {content: 'zzz'}); - assert(isBuffer(collection.items.one.contents)); - assert(isBuffer(collection.getItem('one').contents)); - assert(collection.getItem('one').contents.toString() === 'aaa'); - assert(collection.getItem('two').contents.toString() === 'zzz'); - }); - }); -}); - -describe('queue', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should emit arguments on addItem', function(done) { - collection.on('addItem', function(args) { - assert(args[0] === 'a'); - assert(args[1] === 'b'); - assert(args[2] === 'c'); - assert(args[3] === 'd'); - assert(args[4] === 'e'); - done(); - }); - - collection.addItem('a', 'b', 'c', 'd', 'e'); - }); - - it('should expose the `queue` property for loading items', function() { - collection.queue.push(collection.item('b', {path: 'b'})); - - collection.addItem('a', {path: 'a'}); - assert(collection.items.hasOwnProperty('a')); - assert(collection.items.hasOwnProperty('b')); - }); - - it('should load all items on the queue when addItem is called', function() { - collection.on('addItem', function(args) { - var len = args.length; - var last = args[len - 1]; - if (typeof last === 'string') { - args[len - 1] = { content: last }; - } - }); - - collection.addItem('a.html', 'aaa'); - collection.addItem('b.html', 'bbb'); - collection.addItem('c.html', 'ccc'); - - assert(collection.items.hasOwnProperty('a.html')); - assert(collection.getItem('a.html').content === 'aaa'); - assert(collection.items.hasOwnProperty('b.html')); - assert(collection.getItem('b.html').content === 'bbb'); - assert(collection.items.hasOwnProperty('c.html')); - assert(collection.getItem('c.html').content === 'ccc'); - }); -}); - -describe('options', function() { - describe('option', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should expose the `option` method', function() { - collection.option('foo', 'bar'); - collection.options.should.have.property('foo', 'bar'); - }); - - it('should be chainable', function() { - collection.option('foo', 'bar') - .addItems('a.hbs') - .addItems('b.hbs') - .addItems('c.hbs'); - - collection.options.should.have.property('foo', 'bar'); - collection.items.should.have.properties([ - 'a.hbs', - 'b.hbs', - 'c.hbs' - ]); - }); - - it('should set a key/value pair on options', function() { - collection.option('a', 'b'); - assert(collection.options.a === 'b'); - }); - - it('should set an object on options', function() { - collection.option({c: 'd'}); - assert(collection.options.c === 'd'); - }); - - it('should get an option', function() { - collection.option({c: 'd'}); - var c = collection.option('c'); - assert(c === 'd'); - }); - }); - - describe('options.renameKey', function() { - beforeEach(function() { - collection = new Collection({ - renameKey: function(key) { - return path.basename(key); - } - }); - }); - - it('should use a custom rename key function on item keys', function() { - collection.addItem('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.items['d.hbs'].contents.toString() === 'foo bar baz'); - }); - - it('should get a item with the renamed key', function() { - collection.addItem('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.getItem('d.hbs').contents.toString() === 'foo bar baz'); - }); - - it('should get a item with the original key', function() { - collection.addItem('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.getItem('a/b/c/d.hbs').contents.toString() === 'foo bar baz'); - }); - }); -}); - diff --git a/vendors/update/test/collection.options.js b/vendors/update/test/collection.options.js deleted file mode 100644 index d1af0af9..00000000 --- a/vendors/update/test/collection.options.js +++ /dev/null @@ -1,25 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('collection.option()', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - }); - - it('should set an option:', function() { - app.pages.options.should.not.have.property('foo'); - app.pages.option('foo', 'bar'); - app.pages.options.should.have.property('foo'); - }); - - it('should extend options:', function() { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}); - app.pages.option('a', 'b'); - app.pages.option('c', 'd'); - app.pages.option('e', 'f'); - app.pages.options.should.have.properties(['a', 'c', 'e']); - }); -}); diff --git a/vendors/update/test/collection.render.js b/vendors/update/test/collection.render.js deleted file mode 100644 index 896c8050..00000000 --- a/vendors/update/test/collection.render.js +++ /dev/null @@ -1,138 +0,0 @@ -require('mocha'); -require('should'); -var async = require('async'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var Views = App.Views; -var pages; - -describe('render', function() { - describe('rendering', function() { - beforeEach(function() { - pages = new Views(); - pages.engine('tmpl', require('engine-base')); - }); - - it('should throw an error when no callback is given:', function() { - (function() { - pages.render({}); - }).should.throw('Views#render is async and expects a callback function'); - }); - - it('should throw an error when an engine is not defined:', function(done) { - pages.addView('foo.bar', {content: '<%= name %>'}); - var page = pages.getView('foo.bar'); - - pages.render(page, function(err) { - assert(err.message === 'Views#render cannot find an engine for: .bar'); - done(); - }); - }); - - it('should use helpers to render a view:', function(done) { - var locals = {name: 'Halle'}; - - pages.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - pages.addView('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getView('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - - assert(res.content === 'a HALLE b'); - done(); - }); - }); - - it('should use helpers when rendering a view:', function(done) { - var locals = {name: 'Halle'}; - pages.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - pages.addView('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getView('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - assert(res.content === 'a HALLE b'); - done(); - }); - }); - - it('should render a template when contents is a buffer:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = pages.getView('a.tmpl'); - - pages.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a template when content is a string:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var view = pages.getView('a.tmpl'); - - pages.render(view, function(err, view) { - if (err) return done(err); - assert(view.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a view from its path:', function(done) { - pages.addView('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - - pages.render('a.tmpl', function(err, view) { - if (err) return done(err); - assert(view.content === 'b'); - done(); - }); - }); - - it('should use a plugin for rendering:', function(done) { - pages.engine('tmpl', require('engine-base')); - pages.option('engine', 'tmpl'); - - pages.addViews({ - 'a': {content: '<%= title %>', locals: {title: 'aaa'}}, - 'b': {content: '<%= title %>', locals: {title: 'bbb'}}, - 'c': {content: '<%= title %>', locals: {title: 'ccc'}}, - 'd': {content: '<%= title %>', locals: {title: 'ddd'}}, - 'e': {content: '<%= title %>', locals: {title: 'eee'}}, - 'f': {content: '<%= title %>', locals: {title: 'fff'}}, - 'g': {content: '<%= title %>', locals: {title: 'ggg'}}, - 'h': {content: '<%= title %>', locals: {title: 'hhh'}}, - 'i': {content: '<%= title %>', locals: {title: 'iii'}}, - 'j': {content: '<%= title %>', locals: {title: 'jjj'}} - }); - - pages.use(function(collection) { - collection.option('pager', false); - - collection.renderEach = function(cb) { - var list = new List(collection); - - async.map(list.items, function(item, next) { - collection.render(item, next); - }, cb); - }; - }); - - pages.renderEach(function(err, items) { - if (err) return done(err); - assert(items[0].content === 'aaa'); - assert(items[9].content === 'jjj'); - assert(items.length === 10); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/collection.use.js b/vendors/update/test/collection.use.js deleted file mode 100644 index f09bd864..00000000 --- a/vendors/update/test/collection.use.js +++ /dev/null @@ -1,156 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Collection = App.Collection; -var Item = App.Item; -var collection; - -describe('collection.use', function() { - beforeEach(function() { - collection = new Collection(); - }); - - it('should expose the instance to `use`:', function(done) { - collection.use(function(inst) { - assert(inst instanceof Collection); - done(); - }); - }); - - it('should be chainable:', function(done) { - collection.use(function(inst) { - assert(inst instanceof Collection); - }) - .use(function(inst) { - assert(inst instanceof Collection); - }) - .use(function(inst) { - assert(inst instanceof Collection); - done(); - }); - }); - - it('should expose the collection to a plugin:', function() { - collection.use(function(items) { - assert(items instanceof Collection); - items.foo = items.addItem.bind(items); - }); - - collection.foo('a', {content: '...'}); - assert(collection.items.hasOwnProperty('a')); - }); - - it('should expose collection when chained:', function() { - collection - .use(function(items) { - assert(items instanceof Collection); - items.foo = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof Collection); - items.bar = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof Collection); - items.baz = items.addItem.bind(items); - }); - - var pages = collection; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(collection.items.hasOwnProperty('a')); - assert(collection.items.hasOwnProperty('b')); - assert(collection.items.hasOwnProperty('c')); - }); - - it('should work when a custom `Item` constructor is passed:', function() { - collection = new Collection({Item: require('vinyl')}); - collection - .use(function(items) { - assert(items instanceof Collection); - items.foo = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof Collection); - items.bar = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof Collection); - items.baz = items.addItem.bind(items); - }); - - var pages = collection; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(collection.items.hasOwnProperty('a')); - assert(collection.items.hasOwnProperty('b')); - assert(collection.items.hasOwnProperty('c')); - }); - - it('should pass to item `use` if a function is returned:', function() { - collection.use(function(items) { - assert(items instanceof Collection); - - return function(item) { - item.foo = items.addItem.bind(items); - assert(item instanceof Item); - }; - }); - - collection.addItem('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .foo({path: 'c', content: '...'}) - .foo({path: 'd', content: '...'}); - - assert(collection.items.hasOwnProperty('a')); - assert(collection.items.hasOwnProperty('b')); - assert(collection.items.hasOwnProperty('c')); - assert(collection.items.hasOwnProperty('d')); - }); - - it('should be chainable when a item function is returned:', function() { - collection - .use(function(items) { - assert(items instanceof Collection); - - return function(item) { - item.foo = items.addItem.bind(items); - assert(item instanceof Item); - }; - }) - .use(function(items) { - assert(items instanceof Collection); - - return function(item) { - item.bar = items.addItem.bind(items); - assert(item instanceof Item); - }; - }) - .use(function(items) { - assert(items instanceof Collection); - - return function(item) { - item.baz = items.addItem.bind(items); - assert(item instanceof Item); - }; - }); - - collection.addItem('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .bar({path: 'c', content: '...'}) - .baz({path: 'd', content: '...'}); - - assert(collection.items.hasOwnProperty('a')); - assert(collection.items.hasOwnProperty('b')); - assert(collection.items.hasOwnProperty('c')); - assert(collection.items.hasOwnProperty('d')); - }); -}); diff --git a/vendors/update/test/fixtures/bom-utf16be.txt b/vendors/update/test/fixtures/bom-utf16be.txt deleted file mode 100644 index b9dce78a5d31af4803acd1a0f0dfc14f064a5de1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmX|+I}XAy5Jacu26Qf=0Eq@sM*@i=qJaY#5&}waq&RRn3Xa4Tc-{cbe#Sc=zn?E@ zuZymVayru+l}y7P<@I1MK)hWXxZY@{g_hJzYt4Dvs;8dRDlmE2!LB37&GahJPDg5G zyEjIUb8?Hu>i*d9+Q4pAn^J>j{bf4+Qmn{O;+32Wrj#?&PC0#o+uan?UxFJmPf0ua E03tFf0ssI2 diff --git a/vendors/update/test/fixtures/bom-utf16le.txt b/vendors/update/test/fixtures/bom-utf16le.txt deleted file mode 100644 index 07cc600c98675d221bb56d10af38e650538734c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmX|+%?`mp6otRFH?W%}3lbZ#mXJt@4G%E1O4?47PI);CkK`4cxy9!GoVn*`-p>~Y zuH1+?F6tGzrhboj9@;Y@-Y$;1UNd3FTy@Kesopkps%IL4CNFld>nNl)y+UZqNwu)u z8>5qRa*M`l|5*Q8iQQ0|QYFpu%XIuwER-RaS8~oYrJPIl?9@kcyPIPAOJL|a#!5Tj E15l{{title}}

-

<%= title() %>

\ No newline at end of file diff --git a/vendors/update/test/fixtures/pages/b.hbs b/vendors/update/test/fixtures/pages/b.hbs deleted file mode 100644 index 51320bdc..00000000 --- a/vendors/update/test/fixtures/pages/b.hbs +++ /dev/null @@ -1,2 +0,0 @@ -

{{title}}

-

<%= title() %>

\ No newline at end of file diff --git a/vendors/update/test/fixtures/pages/c.hbs b/vendors/update/test/fixtures/pages/c.hbs deleted file mode 100644 index 51320bdc..00000000 --- a/vendors/update/test/fixtures/pages/c.hbs +++ /dev/null @@ -1,2 +0,0 @@ -

{{title}}

-

<%= title() %>

\ No newline at end of file diff --git a/vendors/update/test/fixtures/pipeline/a.js b/vendors/update/test/fixtures/pipeline/a.js deleted file mode 100644 index 1085b602..00000000 --- a/vendors/update/test/fixtures/pipeline/a.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var through = require('through2'); - -module.exports = function(options) { - return through.obj(function(file, enc, cb) { - var str = file.contents.toString(); - str += 'aaa\n'; - - // var err = new Error('foo'); - // err.plugin = 'a'; - // this.emit('error', err); - // return cb(err); - - file.contents = new Buffer(str); - this.push(file); - cb(); - }); -}; diff --git a/vendors/update/test/fixtures/pipeline/b.js b/vendors/update/test/fixtures/pipeline/b.js deleted file mode 100644 index e0b05217..00000000 --- a/vendors/update/test/fixtures/pipeline/b.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var through = require('through2'); - -module.exports = function(options) { - return through.obj(function(file, enc, cb) { - var str = file.contents.toString(); - str += 'bbb\n'; - - file.contents = new Buffer(str); - this.push(file); - cb(); - }); -}; diff --git a/vendors/update/test/fixtures/pipeline/c.js b/vendors/update/test/fixtures/pipeline/c.js deleted file mode 100644 index f5c0a47b..00000000 --- a/vendors/update/test/fixtures/pipeline/c.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var through = require('through2'); - -module.exports = function(options) { - return through.obj(function(file, enc, cb) { - var str = file.contents.toString(); - str += 'ccc\n'; - - file.contents = new Buffer(str); - this.push(file); - cb(); - }); -}; diff --git a/vendors/update/test/fixtures/pipeline/d.js b/vendors/update/test/fixtures/pipeline/d.js deleted file mode 100644 index 636f53e7..00000000 --- a/vendors/update/test/fixtures/pipeline/d.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var through = require('through2'); - -module.exports = function(options) { - return through.obj(function(file, enc, cb) { - var str = file.contents.toString(); - str += 'ddd\n'; - - file.contents = new Buffer(str); - this.push(file); - cb(); - }); -}; diff --git a/vendors/update/test/fixtures/posts/a.txt b/vendors/update/test/fixtures/posts/a.txt deleted file mode 100644 index bca29ee6..00000000 --- a/vendors/update/test/fixtures/posts/a.txt +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: AAA ---- -This is <%= title %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/posts/b.txt b/vendors/update/test/fixtures/posts/b.txt deleted file mode 100644 index 1e128c70..00000000 --- a/vendors/update/test/fixtures/posts/b.txt +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: BBB ---- -This is <%= title %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/posts/c.txt b/vendors/update/test/fixtures/posts/c.txt deleted file mode 100644 index 32f91870..00000000 --- a/vendors/update/test/fixtures/posts/c.txt +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: CCC ---- -This is <%= title %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/templates/a.tmpl b/vendors/update/test/fixtures/templates/a.tmpl deleted file mode 100644 index 36f1f1b5..00000000 --- a/vendors/update/test/fixtures/templates/a.tmpl +++ /dev/null @@ -1 +0,0 @@ -<%= name %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/templates/b.tmpl b/vendors/update/test/fixtures/templates/b.tmpl deleted file mode 100644 index 36f1f1b5..00000000 --- a/vendors/update/test/fixtures/templates/b.tmpl +++ /dev/null @@ -1 +0,0 @@ -<%= name %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/templates/c.tmpl b/vendors/update/test/fixtures/templates/c.tmpl deleted file mode 100644 index 36f1f1b5..00000000 --- a/vendors/update/test/fixtures/templates/c.tmpl +++ /dev/null @@ -1 +0,0 @@ -<%= name %> \ No newline at end of file diff --git a/vendors/update/test/fixtures/test-symlink-dir/suchempty b/vendors/update/test/fixtures/test-symlink-dir/suchempty deleted file mode 100644 index 65bbcaab..00000000 --- a/vendors/update/test/fixtures/test-symlink-dir/suchempty +++ /dev/null @@ -1 +0,0 @@ -suchempty \ No newline at end of file diff --git a/vendors/update/test/fixtures/test.coffee b/vendors/update/test/fixtures/test.coffee deleted file mode 100644 index 6769dd60..00000000 --- a/vendors/update/test/fixtures/test.coffee +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendors/update/test/fixtures/updaters/a.txt b/vendors/update/test/fixtures/updaters/a.txt deleted file mode 100644 index 7c4a013e..00000000 --- a/vendors/update/test/fixtures/updaters/a.txt +++ /dev/null @@ -1 +0,0 @@ -aaa \ No newline at end of file diff --git a/vendors/update/test/fixtures/updaters/b.txt b/vendors/update/test/fixtures/updaters/b.txt deleted file mode 100644 index 01f02e32..00000000 --- a/vendors/update/test/fixtures/updaters/b.txt +++ /dev/null @@ -1 +0,0 @@ -bbb \ No newline at end of file diff --git a/vendors/update/test/fixtures/updaters/c.txt b/vendors/update/test/fixtures/updaters/c.txt deleted file mode 100644 index 2383bd58..00000000 --- a/vendors/update/test/fixtures/updaters/c.txt +++ /dev/null @@ -1 +0,0 @@ -ccc \ No newline at end of file diff --git a/vendors/update/test/fixtures/vinyl/bom-utf16be.txt b/vendors/update/test/fixtures/vinyl/bom-utf16be.txt deleted file mode 100644 index b9dce78a5d31af4803acd1a0f0dfc14f064a5de1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmX|+I}XAy5Jacu26Qf=0Eq@sM*@i=qJaY#5&}waq&RRn3Xa4Tc-{cbe#Sc=zn?E@ zuZymVayru+l}y7P<@I1MK)hWXxZY@{g_hJzYt4Dvs;8dRDlmE2!LB37&GahJPDg5G zyEjIUb8?Hu>i*d9+Q4pAn^J>j{bf4+Qmn{O;+32Wrj#?&PC0#o+uan?UxFJmPf0ua E03tFf0ssI2 diff --git a/vendors/update/test/fixtures/vinyl/bom-utf16le.txt b/vendors/update/test/fixtures/vinyl/bom-utf16le.txt deleted file mode 100644 index 07cc600c98675d221bb56d10af38e650538734c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmX|+%?`mp6otRFH?W%}3lbZ#mXJt@4G%E1O4?47PI);CkK`4cxy9!GoVn*`-p>~Y zuH1+?F6tGzrhboj9@;Y@-Y$;1UNd3FTy@Kesopkps%IL4CNFld>nNl)y+UZqNwu)u z8>5qRa*M`l|5*Q8iQQ0|QYFpu%XIuwER-RaS8~oYrJPIl?9@kcyPIPAOJL|a#!5Tj E15l', locals: {a: 'bbb'}}); - app.helper('upper', function(str) { - return str.toUpperCase(); - }); - - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return cb(err); - - assert.equal(typeof view.contents.toString(), 'string'); - assert.equal(view.contents.toString(), 'BBB'); - cb(); - }); - }); - - it('should use a namespaced helper:', function(cb) { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= foo.upper(a) %>', locals: {a: 'bbb'}}); - - app.helperGroup('foo', { - upper: function(str) { - return str.toUpperCase(); - } - }); - - // console.log(app._.helpers) - - var page = app.pages.getView('a.tmpl'); - app.render(page, function(err, view) { - if (err) return cb(err); - - assert.equal(typeof view.contents.toString(), 'string'); - assert.equal(view.contents.toString(), 'BBB'); - cb(); - }); - }); -}); - -describe('async helpers', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - it('should register an async helper:', function() { - app.asyncHelper('a', function() {}); - app.asyncHelper('b', function() {}); - app._.helpers.async.should.have.property('a'); - app._.helpers.async.should.have.property('b'); - }); - - it('should use an async helper:', function(cb) { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= lower(a) %>', locals: {a: 'BBB'}}); - app.asyncHelper('lower', function(str, next) { - if (typeof next !== 'function') return str; - next(null, str.toLowerCase()); - }); - - var page = app.pages.getView('a.tmpl'); - app.render(page, function(err, view) { - if (err) return cb(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'bbb'); - cb(); - }); - }); -}); - -describe('built-in helpers:', function() { - describe('automatically generated helpers for default view types:', function() { - beforeEach(function() { - app = new App({rethrow: false}); - app.engine('md', require('engine-base')); - app.engine('tmpl', require('engine-base')); - app.create('partials', { viewType: 'partial' }); - app.create('pages'); - - // parse front matter - app.onLoad(/./, function(view, next) { - matter.parse(view, next); - }); - }); - - it('should expose front matter to the `partial` helper.', function(cb) { - app.partial('a.md', {content: '---\nname: "AAA"\n---\n<%= name %>', locals: {name: 'BBB'}}); - app.page('b.md', {path: 'b.md', content: 'foo <%= partial("a.md") %> bar'}); - - app.render('b.md', function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo AAA bar'); - cb(); - }); - }); - - it('should use helper locals.', function(cb) { - app.partial('abc.md', {content: '<%= name %>', locals: {name: 'BBB'}}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md", { name: "CCC" }) %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo CCC bar'); - cb(); - }); - }); - - it('should use front matter data.', function(cb) { - app.partial('abc.md', {content: '---\nname: "AAA"\n---\n<%= name %>'}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo AAA bar'); - cb(); - }); - }); - - it('should prefer helper locals over front-matter', function(cb) { - app.partial('abc.md', {content: '---\nname: "AAA"\n---\n<%= name %>', locals: {name: 'BBB'}}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md", { name: "CCC" }) %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo CCC bar'); - cb(); - }); - }); - - it('should use partial locals:', function(cb) { - app.partial('abc.md', {content: '<%= name %>', locals: {name: 'EEE'}}); - - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}) - .render({name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo EEE bar'); - cb(); - }); - }); - - it('should use locals from the `view.render` method:', function(cb) { - app.partial('abc.md', {content: '<%= name %>', locals: {name: 'EEE'}}); - - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}) - .render({name: 'DDD'}, function(err, res) { - if (err) return cb(err); - - res.content.should.equal('foo EEE bar'); - cb(); - }); - }); - - it('should use locals from the `app.render` method:', function(cb) { - app.partial('abc.md', {content: '<%= name %>'}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo DDD bar'); - cb(); - }); - }); - - it('should use a `helperContext` function from app.options', function(cb) { - app.option('helperContext', function(view, locals) { - return { name: 'blah' }; - }); - - app.partial('abc.md', {content: '<%= name %>'}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo blah bar'); - cb(); - }); - }); - - it('should return an empty string when the partial is missing.', function(cb) { - app.partial('abc.md', {content: '---\nname: "AAA"\n---\n<%= name %>', locals: {name: 'BBB'}}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("def.md", { name: "CCC" }) %> bar'}); - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo bar'); - cb(); - }); - }); - }); - - describe('helper context:', function() { - beforeEach(function() { - app = new App({rethrow: false}); - app.engine(['tmpl', 'md'], require('engine-base')); - app.create('partial', { viewType: 'partial' }); - app.create('page'); - - // parse front matter - app.onLoad(/./, function(view, next) { - matter.parse(view, next); - }); - }); - - it('should prefer helper locals over view locals.', function(cb) { - app.partial('abc.md', {content: '<%= name %>', name: 'BBB'}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md", { name: "CCC" }) %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo CCC bar'); - cb(); - }); - }); - - it('should give preference to view locals over render locals.', function(cb) { - app.partial('abc.md', {content: '<%= name %>', locals: {name: 'BBB'}}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}); - - var page = app.pages.getView('xyz.md'); - - app.render(page, {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo BBB bar'); - cb(); - }); - }); - - it('should use render locals when other locals are not defined.', function(cb) { - app.partial('abc.md', {content: '<%= name %>'}); - app.page('xyz.md', {path: 'xyz.md', content: 'foo <%= partial("abc.md") %> bar'}); - - app.render('xyz.md', {name: 'DDD'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo DDD bar'); - cb(); - }); - }); - }); - - describe('user-defined engines:', function() { - beforeEach(function() { - app = new App({rethrow: false}); - app.create('partial', { viewType: 'partial' }); - app.create('page'); - - // parse front matter - app.onLoad(/./, function(view, next) { - matter.parse(view, next); - }); - }); - - it('should use the `partial` helper with handlebars.', function(cb) { - app.engine(['tmpl', 'md'], require('engine-base')); - app.engine('hbs', handlebars); - - app.partial('title.hbs', {content: '{{name}}', locals: {name: 'BBB'}}); - app.page('a.hbs', {path: 'a.hbs', content: 'foo {{{partial "title.hbs" this}}} bar'}); - - app.render('a.hbs', {name: 'Halle Nicole'}, function(err, res) { - if (err) return cb(err); - res.content.should.equal('foo Halle Nicole bar'); - cb(); - }); - }); - - it('should use the `partial` helper with any engine.', function(cb) { - app.engine('hbs', handlebars); - app.engine('md', handlebars); - app.engine('swig', swig); - app.engine('tmpl', require('engine-base')); - - /** - * Partial - */ - - app.partial('a.hbs', { - content: '---\nname: "AAA"\n---\n{{name}}', - locals: { - name: 'BBB' - } - }); - - /** - * Pages - */ - - app.page('a.hbs', { - path: 'a.hbs', - content: '{{author}}', - locals: { - author: 'Halle Nicole' - } - }); - app.page('b.tmpl', { - path: 'b.tmpl', - content: '<%= author %>', - locals: { - author: 'Halle Nicole' - } - }); - app.page('d.swig', { - path: 'd.swig', - content: '{{author}}', - locals: { - author: 'Halle Nicole' - } - }); - app.page('e.swig', { - path: 'e.swig', - content: '{{author}}', - locals: { - author: 'Halle Nicole' - } - }); - app.page('f.hbs', { - content: '{{author}}', - locals: { - author: 'Halle Nicole' - } - }); - app.page('g.md', { - content: '---\nauthor: Brian Woodward\n---\n{{author}}', - locals: { - author: 'Halle Nicole' - } - }); - app.page('with-partial.hbs', { - path: 'with-partial.hbs', - content: '{{{partial "a.hbs" custom.locals}}}' - }); - - app.on('error', function(err) { - cb(err); - }); - - var locals = {custom: {locals: {name: 'Halle Nicole' }}}; - app.render('a.hbs', locals, function(err, res) { - if (err) { - app.emit('error', err); - return; - } - res.content.should.equal('Halle Nicole'); - }); - - app.render('with-partial.hbs', locals, function(err, res) { - if (err) { - app.emit('error', err); - return; - } - res.content.should.equal('Halle Nicole'); - }); - - var page = app.pages.getView('g.md'); - locals.author = page.data.author || locals.author; - page.render(locals, function(err, res) { - if (err) { - app.emit('error', err); - return; - } - res.content.should.equal('Brian Woodward'); - cb(null, res.content); - }); - }); - }); -}); - -describe('helpers integration', function() { - beforeEach(function() { - app = new App(); - app.create('pages'); - app.engine('md', require('engine-base')); - }); - - describe('.helpers()', function() { - it('should add helpers and use them in templates.', function(cb) { - app.helpers({ - upper: function(str) { - return str.toUpperCase(); - } - }); - - app.page('doc.md', {content: 'a <%= upper(name) %> b'}) - .render({name: 'Halle'}, function(err, res) { - if (err) return cb(err); - assert(res.content === 'a HALLE b'); - cb(); - }); - }); - }); - - describe('helper options:', function() { - it('should expose `this.options` to helpers:', function(cb) { - app.helper('cwd', function(fp) { - return path.join(this.options.cwd, fp); - }); - - app.option('one', 'two'); - app.option('cwd', 'foo/bar'); - app.page('doc.md', {content: 'a <%= cwd("baz") %> b'}) - .render(function(err, res) { - if (err) return cb(err); - assert(res.content === 'a foo/bar/baz b'); - cb(); - }); - }); - - it('should pass helper options to helpers:', function(cb) { - app.helper('cwd', function(fp) { - return path.join(this.options.cwd, fp); - }); - - app.option('helper.cwd', 'foo/bar'); - app.option('helper.whatever', '...'); - - app.page('doc.md', {content: 'a <%= cwd("baz") %> b'}) - .render(function(err, res) { - if (err) return cb(err); - assert(res.content === 'a foo/bar/baz b'); - cb(); - }); - }); - }); - - describe('options.helpers', function() { - it('should register helpers passed on the options:', function(cb) { - app.option({ - helpers: { - upper: function(str) { - return str.toUpperCase(); - }, - foo: function(str) { - return 'foo' + str; - } - } - }); - - app.page('doc.md', {content: 'a <%= upper(name) %> <%= foo("bar") %> b'}) - .render({name: 'Halle'}, function(err, res) { - if (err) return cb(err); - assert(res.content === 'a HALLE foobar b'); - cb(); - }); - }); - }); - - describe('options.helpers', function() { - it('should add helpers and use them in templates.', function(cb) { - app.options.helpers = { - upper: function(str) { - return str.toUpperCase(); - }, - foo: function(str) { - return 'foo' + str; - } - }; - - app.page('doc.md', {content: 'a <%= upper(name) %> b'}) - .render({name: 'Halle'}, function(err, res) { - if (err) return cb(err); - assert(res.content === 'a HALLE b'); - cb(); - }); - }); - }); -}); - -describe('collection helpers', function() { - beforeEach(function() { - app = new App(); - app.create('posts'); - app.create('pages', {engine: 'hbs'}); - app.create('partials', {viewType: 'partial', engine: 'hbs'}); - app.create('snippet', {viewType: 'partial'}); - app.engine('hbs', require('engine-handlebars')); - app.helper('log', function(ctx) { - console.log(ctx); - }); - }); - - describe('plural', function() { - it('should get the given collection', function(cb) { - app.post('a.hbs', {content: 'foo'}); - app.post('b.hbs', {content: 'bar'}); - app.post('c.hbs', {content: 'baz'}); - - app.partial('list.hbs', { - content: '{{#posts}}{{#each items}}{{content}}{{/each}}{{/posts}}' - }); - - app.page('index.hbs', { - content: '{{> list.hbs }}' - }) - .render(function(err, res) { - if (err) return cb(err); - assert(res.content === 'foobarbaz'); - cb(); - }); - }); - }); - - describe('single', function() { - it('should get a view from an unspecified collection', function(cb) { - app.post('a.hbs', {content: 'post-a'}); - app.post('b.hbs', {content: 'post-b'}); - - var one = app.page('one', {content: '{{view "a.hbs"}}'}) - .compile() - .fn(); - - var two = app.page('two', {content: '{{view "b.hbs"}}'}) - .compile() - .fn(); - - assert(one === 'post-a'); - assert(two === 'post-b'); - cb(); - }); - - it('should return an empty string if not found', function(cb) { - var one = app.page('one', {content: '{{view "foo.hbs"}}'}) - .compile() - .fn(); - assert(one === ''); - cb(); - }); - - it('should handle engine errors', function(cb) { - app.post('foo.hbs', {content: '{{one "two"}}'}); - app.page('one', {content: '{{posts "foo.hbs"}}'}) - .render(function(err) { - assert(err); - assert(typeof err === 'object'); - assert(typeof err.message === 'string'); - assert(/Missing helper: "one"/.test(err.message)); - cb(); - }); - }); - - it('should handle engine errors2', function(cb) { - app.engine('tmpl', require('engine-base')); - app.create('foo', {engine: 'tmpl'}); - app.create('bar', {engine: 'tmpl'}); - - app.create('foo', {viewType: 'partial'}); - app.foo('foo.tmpl', {path: 'foo.tmpl', content: '<%= blah.bar %>'}); - app.bar('one.tmpl', {content: '<%= foo("foo.tmpl") %>'}) - .render(function(err) { - assert(err); - assert(typeof err === 'object'); - assert(/blah is not defined/.test(err.message)); - cb(); - }); - }); - - it('should work with non-handlebars engine', function(cb) { - app.engine('tmpl', require('engine-base')); - app.create('foo', {engine: 'tmpl'}); - app.create('bar', {engine: 'tmpl'}); - - app.foo('a.tmpl', {content: 'foo-a'}); - app.foo('b.tmpl', {content: 'foo-b'}); - - var one = app.bar('one', {content: '<%= view("a.tmpl") %>'}) - .compile() - .fn(); - - var two = app.bar('two', {content: '<%= view("b.tmpl") %>'}) - .compile() - .fn(); - - assert(one === 'foo-a'); - assert(two === 'foo-b'); - cb(); - }); - - it('should get a specific view from the given collection', function(cb) { - app.post('a.hbs', {content: 'post-a'}); - app.post('b.hbs', {content: 'post-b'}); - app.post('c.hbs', {content: 'post-c'}); - app.page('a.hbs', {content: 'page-a'}); - app.page('b.hbs', {content: 'page-b'}); - app.page('c.hbs', {content: 'page-c'}); - - var one = app.page('one', {content: '{{view "a.hbs" "posts"}}'}) - .compile() - .fn(); - - var two = app.page('two', {content: '{{view "b.hbs" "pages"}}'}) - .compile() - .fn(); - - assert(one === 'post-a'); - assert(two === 'page-b'); - cb(); - }); - }); -}); diff --git a/vendors/update/test/item.js b/vendors/update/test/item.js deleted file mode 100644 index ca0f4354..00000000 --- a/vendors/update/test/item.js +++ /dev/null @@ -1,1060 +0,0 @@ -require('mocha'); -var should = require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var es = require('event-stream'); -var Stream = require('stream'); -var support = require('./support'); -var App = support.resolve(); -var Item = App.Item; -var item; - -describe('Item', function() { - describe('instance', function() { - it('should create an instance of Item:', function() { - item = new Item(); - assert(item instanceof Item); - }); - - it('should instantiate without new:', function() { - item = Item(); - assert(item instanceof Item); - }); - - it('inspect should not double name `Stream` when ctor is `Stream`', function(done) { - var val = new Stream(); - item = new Item({contents: val}); - done(); - }); - }); - - describe('static methods', function() { - it('should expose `extend`:', function() { - assert(typeof Item.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - item = new Item(); - }); - - it('should expose `set`:', function() { - assert(typeof item.set === 'function'); - }); - it('should expose `get`:', function() { - assert(typeof item.get === 'function'); - }); - it('should expose `del`:', function() { - assert(typeof item.del === 'function'); - }); - it('should expose `define`:', function() { - assert(typeof item.define === 'function'); - }); - it('should expose `visit`:', function() { - assert(typeof item.visit === 'function'); - }); - }); - - describe('properties', function() { - it('should expose an `options` property', function() { - item = new Item({}); - assert.deepEqual(item.options, {}); - assert(item.hasOwnProperty('options')); - }); - - it('should add `options` when passed on the constructor', function() { - item = new Item({options: {foo: 'bar'}}); - assert(item.options.foo === 'bar'); - }); - - it('should expose a `data` property', function() { - item = new Item({app: {}}); - assert.deepEqual(item.data, {}); - assert(item.hasOwnProperty('data')); - }); - - it('should add `data` when passed on the constructor', function() { - item = new Item({data: {foo: 'bar'}}); - assert(item.data.foo === 'bar'); - }); - - it('should add `locals` when passed on the constructor', function() { - item = new Item({locals: {foo: 'bar'}}); - assert(item.locals.foo === 'bar'); - }); - }); - - describe('set', function() { - it('should set properties on the object', function() { - item = new Item(); - item.set('foo', 'bar'); - assert.equal(item.foo, 'bar'); - }); - }); - - describe('get', function() { - it('should get properties from the object', function() { - item = new Item(); - item.set('foo', 'bar'); - assert.equal(item.get('foo'), 'bar'); - }); - }); - - describe('cwd', function() { - it('should get properties from the object', function() { - item = new Item({cwd: 'test/fixtures'}); - assert(item.cwd === 'test/fixtures'); - }); - }); - - describe('clone', function() { - it('should clone the item:', function() { - item = new Item({content: 'foo'}); - item.set({path: 'foo/bar'}); - item.set('options.one', 'two'); - var clone = item.clone(); - assert(clone.contents); - clone.set('baz', 'quux'); - clone.set('options.three', 'four'); - assert.equal(clone.get('foo'), item.get('foo')); - assert(clone.get('baz') === 'quux'); - assert(!item.get('baz')); - // not deep cloned - assert(clone.get('options.three') === 'four'); - assert(item.get('options.three') === 'four'); - }); - - it('should deep clone the entire object', function() { - item = new Item({content: 'foo'}); - item.set({path: 'foo/bar'}); - item.set('options.one', 'two'); - var clone = item.clone({deep: true}); - clone.set('options.three', 'four'); - assert(item.get('options.one') === 'two'); - assert(clone.get('options.one') === 'two'); - assert(clone.get('options.three') === 'four'); - assert(!item.get('options.three')); - }); - }); - - describe('visit', function() { - it('should visit all properties on an object and call the specified method', function() { - item = new Item(); - var obj = { - foo: 'bar', - bar: 'baz', - baz: 'bang' - }; - item.visit('set', obj); - assert.equal(item.get('foo'), 'bar'); - assert.equal(item.get('bar'), 'baz'); - assert.equal(item.get('baz'), 'bang'); - }); - - it('should visit all properties on all objects in an array and call the specified method', function() { - item = new Item(); - var arr = [{foo: 'bar', bar: 'baz', baz: 'bang'}]; - item.visit('set', arr); - assert.equal(item.get('foo'), 'bar'); - assert.equal(item.get('bar'), 'baz'); - assert.equal(item.get('baz'), 'bang'); - }); - }); -}); - -/** - * The following unit tests are from Vinyl - * Since we inherit vinyl in Item, we need - * to ensure that these still pass. - */ - -describe('Item', function() { - describe('isVinyl()', function() { - it('should return true on a vinyl object', function(done) { - item = new Item(); - assert(Item.isVinyl(item) === true); - done(); - }); - it('should return false on a normal object', function(done) { - assert(Item.isVinyl({}) === false); - done(); - }); - it('should return false on a null object', function(done) { - assert(Item.isVinyl({}) === false); - done(); - }); - }); - - describe('constructor()', function() { - it('should default cwd to process.cwd', function(done) { - item = new Item(); - item.cwd.should.equal(process.cwd()); - done(); - }); - - it('should default base to cwd', function(done) { - var cwd = '/'; - item = new Item({cwd: cwd}); - item.base.should.equal(cwd); - done(); - }); - - it('should default base to cwd even when none is given', function(done) { - item = new Item(); - item.base.should.equal(process.cwd()); - done(); - }); - - it('should default path to null', function(done) { - item = new Item(); - should.not.exist(item.path); - done(); - }); - - it('should default history to []', function(done) { - item = new Item(); - item.history.should.eql([]); - done(); - }); - - it('should default stat to null', function(done) { - item = new Item(); - should.not.exist(item.stat); - done(); - }); - - it('should default contents to null', function(done) { - item = new Item(); - should.not.exist(item.contents); - done(); - }); - - it('should set base to given value', function(done) { - var val = '/'; - item = new Item({base: val}); - item.base.should.equal(val); - done(); - }); - - it('should set cwd to given value', function(done) { - var val = '/'; - item = new Item({cwd: val}); - item.cwd.should.equal(val); - done(); - }); - - it('should set path to given value', function(done) { - var val = '/test.coffee'; - item = new Item({path: val}); - item.path.should.equal(val); - item.history.should.eql([val]); - done(); - }); - - it('should set history to given value', function(done) { - var val = '/test.coffee'; - item = new Item({history: [val]}); - item.path.should.equal(val); - item.history.should.eql([val]); - done(); - }); - - it('should set stat to given value', function(done) { - var val = {}; - item = new Item({stat: val}); - item.stat.should.equal(val); - done(); - }); - - it('should set contents to given value', function(done) { - var val = new Buffer('test'); - item = new Item({contents: val}); - item.contents.should.equal(val); - done(); - }); - }); - - describe('isBuffer()', function() { - it('should return true when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - item = new Item({contents: val}); - item.isBuffer().should.equal(true); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var item = new Item({contents: val}); - item.isBuffer().should.equal(false); - done(); - }); - - it('should return false when the contents are a null', function(done) { - var item = new Item({contents: null}); - item.isBuffer().should.equal(false); - done(); - }); - }); - - describe('isStream()', function() { - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var item = new Item({contents: val}); - item.isStream().should.equal(false); - done(); - }); - - it('should return true when the contents are a Stream', function(done) { - var val = new Stream(); - var item = new Item({contents: val}); - item.isStream().should.equal(true); - done(); - }); - - it('should return false when the contents are a null', function(done) { - var item = new Item({contents: null}); - item.isStream().should.equal(false); - done(); - }); - }); - - describe('isNull()', function() { - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var item = new Item({contents: val}); - item.isNull().should.equal(false); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var item = new Item({contents: val}); - item.isNull().should.equal(false); - done(); - }); - - it('should return true when the contents are a null', function(done) { - var item = new Item({contents: null}); - item.isNull().should.equal(true); - done(); - }); - }); - - describe('isDirectory()', function() { - var fakeStat = { - isDirectory: function() { - return true; - } - }; - - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var item = new Item({contents: val, stat: fakeStat}); - item.isDirectory().should.equal(false); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var item = new Item({contents: val, stat: fakeStat}); - item.isDirectory().should.equal(false); - done(); - }); - - it('should return true when the contents are a null', function(done) { - var item = new Item({contents: null, stat: fakeStat}); - item.isDirectory().should.equal(true); - done(); - }); - }); - - describe('clone()', function() { - it('should copy all attributes over with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var item = new Item(options); - var item2 = item.clone(); - - item2.should.not.equal(item, 'refs should be different'); - item2.cwd.should.equal(item.cwd); - item2.base.should.equal(item.base); - item2.path.should.equal(item.path); - item2.contents.should.not.equal(item.contents, 'buffer ref should be different'); - item2.contents.toString('utf8').should.equal(item.contents.toString('utf8')); - done(); - }); - - it('should copy buffer\'s reference with option contents: false', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test') - }; - - var item = new Item(options); - - var copy1 = item.clone({ contents: false }); - copy1.contents.should.equal(item.contents); - - var copy2 = item.clone({}); - copy2.contents.should.not.equal(item.contents); - - var copy3 = item.clone({ contents: 'any string' }); - copy3.contents.should.not.equal(item.contents); - - done(); - }); - - it('should copy all attributes over with Stream', function(done) { - var contents = new Stream.PassThrough(); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: contents - }; - var item = new Item(options); - var item2 = item.clone(); - - contents.write(new Buffer('wa')); - - process.nextTick(function() { - contents.write(new Buffer('dup')); - contents.end(); - }); - - item2.should.not.equal(item, 'refs should be different'); - item2.cwd.should.equal(item.cwd); - item2.base.should.equal(item.base); - item2.path.should.equal(item.path); - item2.contents.should.not.equal(item.contents, 'stream ref should not be the same'); - item.contents.pipe(es.wait(function(err, data) { - if (err) return done(err); - item2.contents.pipe(es.wait(function(err, data2) { - if (err) return done(err); - data2.should.not.equal(data, 'stream contents ref should not be the same'); - data2.should.eql(data, 'stream contents should be the same'); - })); - })); - done(); - }); - - it('should copy all attributes over with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var item = new Item(options); - var item2 = item.clone(); - - item2.should.not.equal(item, 'refs should be different'); - item2.cwd.should.equal(item.cwd); - item2.base.should.equal(item.base); - item2.path.should.equal(item.path); - should.not.exist(item2.contents); - done(); - }); - - it('should properly clone the `stat` property', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test'), - stat: fs.statSync(__filename) - }; - - var item = new Item(options); - var copy = item.clone(); - - assert(copy.stat.isFile()); - assert(!copy.stat.isDirectory()); - done(); - }); - - it('should properly clone the `history` property', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test'), - stat: fs.statSync(__filename) - }; - - var item = new Item(options); - var copy = item.clone(); - - copy.history[0].should.equal(options.path); - copy.path = 'lol'; - item.path.should.not.equal(copy.path); - done(); - }); - - it('should copy custom properties', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var item = new Item(options); - item.custom = { a: 'custom property' }; - var item2 = item.clone(); - - item2.should.not.equal(item, 'refs should be different'); - item2.cwd.should.equal(item.cwd); - item2.base.should.equal(item.base); - item2.path.should.equal(item.path); - item2.custom.should.equal(item.custom); - item2.custom.a.should.equal(item.custom.a); - - done(); - }); - - it('should copy history', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var item = new Item(options); - item.path = '/test/test.js'; - item.path = '/test/test-938di2s.js'; - var item2 = item.clone(); - - item2.history.should.eql([ - '/test/test.coffee', - '/test/test.js', - '/test/test-938di2s.js' - ]); - item2.history.should.not.equal([ - '/test/test.coffee', - '/test/test.js', - '/test/test-938di2s.js' - ]); - item2.path.should.eql('/test/test-938di2s.js'); - - done(); - }); - - it('should copy all attributes deeply', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var item = new Item(options); - item.custom = { a: 'custom property' }; - - var item2 = item.clone(true); - item2.custom.should.eql(item.custom); - item2.custom.should.not.equal(item.custom); - item2.custom.a.should.equal(item.custom.a); - - var item3 = item.clone({ deep: true }); - item3.custom.should.eql(item.custom); - item3.custom.should.not.equal(item.custom); - item3.custom.a.should.equal(item.custom.a); - - var item4 = item.clone(false); - item4.custom.should.eql(item.custom); - item4.custom.should.equal(item.custom); - item4.custom.a.should.equal(item.custom.a); - - var item5 = item.clone({ deep: false }); - item5.custom.should.eql(item.custom); - item5.custom.should.equal(item.custom); - item5.custom.a.should.equal(item.custom.a); - - done(); - }); - }); - - describe('pipe()', function() { - it('should write to stream with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(options.contents.toString('utf8')); - }); - stream.on('end', function() { - done(); - }); - var ret = item.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should pipe to stream with Stream', function(done) { - var testChunk = new Buffer('test'); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(testChunk.toString('utf8')); - done(); - }); - var ret = item.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - - item.contents.write(testChunk); - }); - - it('should do nothing with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function() { - throw new Error('should not write'); - }); - stream.on('end', function() { - done(); - }); - var ret = item.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should write to stream with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(options.contents.toString('utf8')); - done(); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = item.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should pipe to stream with Stream', function(done) { - var testChunk = new Buffer('test'); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(testChunk.toString('utf8')); - done(); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = item.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - - item.contents.write(testChunk); - }); - - it('should do nothing with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var item = new Item(options); - var stream = new Stream.PassThrough(); - stream.on('data', function() { - throw new Error('should not write'); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = item.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - process.nextTick(done); - }); - }); - - describe('inspect()', function() { - it('should return correct format when no contents and no path', function(done) { - var item = new Item(); - item.inspect().should.equal(''); - done(); - }); - - it('should return correct format when Buffer and no path', function(done) { - var val = new Buffer('test'); - var item = new Item({ - contents: val - }); - item.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Buffer and relative path', function(done) { - var val = new Buffer('test'); - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: val - }); - item.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Buffer and only path and no base', function(done) { - var val = new Buffer('test'); - var item = new Item({ - cwd: '/', - path: '/test/test.coffee', - contents: val - }); - delete item.base; - item.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Stream and relative path', function(done) { - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }); - item.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when null and relative path', function(done) { - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }); - item.inspect().should.equal(''); - done(); - }); - }); - - describe('contents get/set', function() { - it('should work with Buffer', function(done) { - var val = new Buffer('test'); - var item = new Item(); - item.contents = val; - item.contents.should.equal(val); - done(); - }); - - it('should work with Stream', function(done) { - var val = new Stream.PassThrough(); - var item = new Item(); - item.contents = val; - item.contents.should.equal(val); - done(); - }); - - it('should work with null', function(done) { - var val = null; - var item = new Item(); - item.contents = val; - (item.contents === null).should.equal(true); - done(); - }); - - it('should work with string', function(done) { - var val = 'test'; - var item = new Item(); - item.contents = val; - item.contents.should.deepEqual(new Buffer(val)); - done(); - }); - }); - - describe('relative get/set', function() { - it('should error on set', function(done) { - var item = new Item(); - try { - item.relative = 'test'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should error on get when no base', function(done) { - var item = new Item(); - delete item.base; - try { - item.relative; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should error on get when no path', function(done) { - var item = new Item(); - try { - item.relative; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return a relative path from base', function(done) { - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.relative.should.equal('test.coffee'); - done(); - }); - - it('should return a relative path from cwd', function(done) { - var item = new Item({ - cwd: '/', - path: '/test/test.coffee' - }); - item.relative.should.equal(path.join('test', 'test.coffee')); - done(); - }); - }); - - describe('dirname get/set', function() { - it('should error on get when no path', function(done) { - var item = new Item(); - try { - item.dirname; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the dirname of the path', function(done) { - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.dirname.should.equal('/test'); - done(); - }); - - it('should error on set when no path', function(done) { - var item = new Item(); - try { - item.dirname = '/test'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the dirname of the path', function(done) { - var item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.dirname = '/test/foo'; - item.path.should.equal('/test/foo/test.coffee'); - done(); - }); - }); - - describe('basename get/set', function() { - it('should error on get when no path', function(done) { - item = new Item(); - try { - item.basename; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the basename of the path', function(done) { - item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.basename.should.equal('test.coffee'); - done(); - }); - - it('should error on set when no path', function(done) { - item = new Item(); - try { - item.basename = 'test.coffee'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the basename of the path', function(done) { - item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.basename = 'foo.png'; - item.path.should.equal('/test/foo.png'); - done(); - }); - }); - - describe('extname get/set', function() { - it('should error on get when no path', function(done) { - item = new Item(); - try { - item.extname; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the extname of the path', function(done) { - item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.extname.should.equal('.coffee'); - done(); - }); - - it('should error on set when no path', function(done) { - item = new Item(); - try { - item.extname = '.coffee'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the extname of the path', function(done) { - item = new Item({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - item.extname = '.png'; - item.path.should.equal('/test/test.png'); - done(); - }); - }); - - describe('path get/set', function() { - - it('should record history when instantiation', function() { - var item = new Item({ - cwd: '/', - path: '/test/test.coffee' - }); - - item.path.should.eql('/test/test.coffee'); - item.history.should.eql(['/test/test.coffee']); - }); - - it('should record history when path change', function() { - var item = new Item({ - cwd: '/', - path: '/test/test.coffee' - }); - - item.path = '/test/test.js'; - item.path.should.eql('/test/test.js'); - item.history.should.eql(['/test/test.coffee', '/test/test.js']); - - item.path = '/test/test.coffee'; - item.path.should.eql('/test/test.coffee'); - item.history.should.eql(['/test/test.coffee', '/test/test.js', '/test/test.coffee']); - }); - - it('should not record history when set the same path', function() { - var item = new Item({ - cwd: '/', - path: '/test/test.coffee' - }); - - item.path = '/test/test.coffee'; - item.path = '/test/test.coffee'; - item.path.should.eql('/test/test.coffee'); - item.history.should.eql(['/test/test.coffee']); - - // ignore when set empty string - item.path = ''; - item.path.should.eql('/test/test.coffee'); - item.history.should.eql(['/test/test.coffee']); - }); - - it('should throw when set path null in constructor', function() { - (function() { - Item({ - cwd: '/', - path: null - }); - }).should.throw('path should be string'); - }); - - it('should throw when set path null', function() { - item = new Item({ - cwd: '/', - path: 'foo' - }); - - (function() { - item.path = null; - }).should.throw('path should be string'); - }); - }); -}); diff --git a/vendors/update/test/layouts.js b/vendors/update/test/layouts.js deleted file mode 100644 index 76f65bc6..00000000 --- a/vendors/update/test/layouts.js +++ /dev/null @@ -1,127 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('layouts', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('layout', { viewType: 'layout' }); - app.create('page'); - }); - - it('should apply a layout to a view:', function(done) { - app.layout('base', {path: 'base.tmpl', content: 'a {% body %} c'}); - app.pages('a.tmpl', {path: 'a.tmpl', content: 'b', layout: 'base'}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a b c'); - done(); - }); - }); - - it('should not apply a layout when `layoutApplied` is set:', function(done) { - app.layout('base', {path: 'base.tmpl', content: 'a {% body %} c'}); - app.pages('a.tmpl', {path: 'a.tmpl', content: 'b', layout: 'base'}); - var page = app.pages.getView('a.tmpl'); - page.option('layoutApplied', true); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'b'); - done(); - }); - }); - - it('should not apply a layout to itself:', function(done) { - app.layout('base', {path: 'base.tmpl', content: 'a {% body %} c', layout: 'base'}); - app.pages('a.tmpl', {path: 'a.tmpl', content: 'b', layout: 'base'}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a b c'); - done(); - }); - }); - - it('should apply nested layouts to a view:', function(done) { - app.layout('a', {path: 'a.tmpl', content: 'a {% body %} a', layout: 'b'}); - app.layout('b', {path: 'b.tmpl', content: 'b {% body %} b', layout: 'c'}); - app.layout('c', {path: 'c.tmpl', content: 'c {% body %} c', layout: 'base'}); - app.layout('base', {path: 'base.tmpl', content: 'outter {% body %} outter'}); - - app.pages('z.tmpl', {path: 'a.tmpl', content: 'inner', layout: 'a'}); - var page = app.pages.getView('z.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'outter c b a inner a b c outter'); - done(); - }); - }); - - it('should track layout stack history on `layoutStack`:', function(done) { - app.layout('a', {path: 'a.tmpl', content: 'a {% body %} a', layout: 'b'}); - app.layout('b', {path: 'b.tmpl', content: 'b {% body %} b', layout: 'c'}); - app.layout('c', {path: 'c.tmpl', content: 'c {% body %} c', layout: 'base'}); - app.layout('base', {path: 'base.tmpl', content: 'outter {% body %} outter'}); - - app.pages('z.tmpl', {path: 'a.tmpl', content: 'inner', layout: 'a'}); - var page = app.pages.getView('z.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert(view.layoutStack.length === 4); - assert(typeof view.layoutStack[0] === 'object'); - assert(typeof view.layoutStack[0].depth === 'number'); - done(); - }); - }); - - it('should track layout stack history on `layoutStack`:', function(done) { - app.layout('a', {path: 'a.tmpl', content: 'a {% body %} a', layout: 'b'}); - app.layout('b', {path: 'b.tmpl', content: 'b {% body %} b', layout: 'c'}); - app.layout('c', {path: 'c.tmpl', content: 'c {% body %} c', layout: 'base'}); - app.layout('base', {path: 'base.tmpl', content: 'outter {% body %} outter'}); - - app.pages('z.tmpl', {path: 'a.tmpl', content: 'inner', layout: 'a'}); - var page = app.pages.getView('z.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'outter c b a inner a b c outter'); - done(); - }); - }); - - it('should get layouts from `layout` viewTypes:', function(done) { - app.create('section', { viewType: 'layout' }); - app.create('block', { viewType: 'layout' }); - - app.section('a', {path: 'a.tmpl', content: 'a {% body %} a', layout: 'b'}); - app.block('b', {path: 'b.tmpl', content: 'b {% body %} b', layout: 'c'}); - app.section('c', {path: 'c.tmpl', content: 'c {% body %} c', layout: 'base'}); - app.block('base', {path: 'base.tmpl', content: 'outter {% body %} outter'}); - - app.pages('z.tmpl', {path: 'a.tmpl', content: 'inner', layout: 'a'}); - var page = app.pages.getView('z.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'outter c b a inner a b c outter'); - done(); - }); - }); -}); diff --git a/vendors/update/test/list.js b/vendors/update/test/list.js deleted file mode 100644 index 8f9cf5d9..00000000 --- a/vendors/update/test/list.js +++ /dev/null @@ -1,689 +0,0 @@ -require('mocha'); -require('should'); -var path = require('path'); -var get = require('get-value'); -var assert = require('assert'); -var typeOf = require('kind-of'); -var support = require('./support/'); -var isBuffer = require('is-buffer'); -assert.containEql = support.containEql; -var App = support.resolve(); -var List = App.List; -var Views = App.Views; -var list, views; - -describe('list', function() { - describe('constructor', function() { - it('should create an instance of List', function() { - var list = new List(); - assert(list instanceof List); - }); - - it('should instaniate without `new`', function() { - var list = List(); - assert(list instanceof List); - }); - }); - - describe('static methods', function() { - it('should expose `extend`', function() { - assert(typeof List.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - list = new List(); - }); - - var methods = [ - 'use', - 'setItem', - 'addItem', - 'addItems', - 'addList', - 'getItem', - 'constructor', - 'set', - 'get', - 'del', - 'define', - 'visit', - 'on', - 'once', - 'off', - 'emit', - 'listeners', - 'hasListeners' - ]; - - methods.forEach(function(method) { - it('should expose the ' + method + ' method', function() { - assert(typeof list[method] === 'function'); - }); - }); - - it('should expose the isList property', function() { - assert(typeof list.isList === 'boolean'); - }); - - it('should expose the keys property', function() { - assert(Array.isArray(list.keys)); - }); - - it('should expose the queue property', function() { - assert(Array.isArray(list.queue)); - }); - - it('should expose the items property', function() { - assert(Array.isArray(list.items)); - }); - - it('should expose the options property', function() { - assert(typeOf(list.options) === 'object'); - }); - }); - - describe('instance', function() { - beforeEach(function() { - list = new List(); - }); - - it('should set a value on the instance', function() { - list.set('a', 'b'); - assert(list.a === 'b'); - }); - - it('should get a value from the instance', function() { - list.set('a', 'b'); - assert(list.get('a') === 'b'); - }); - }); - - describe('use', function() { - beforeEach(function() { - list = new List(); - }); - - it('should expose the instance to plugins', function() { - list - .use(function(inst) { - inst.foo = 'bar'; - }); - - assert(list.foo === 'bar'); - }); - - it('should expose `item` when the plugin returns a function', function() { - list - .use(function() { - return function(item) { - item.foo = 'bar'; - }; - }); - - list.addItem('aaa'); - list.addItem('bbb'); - list.addItem('ccc'); - - assert(list.items[0].foo === 'bar'); - assert(list.items[1].foo === 'bar'); - assert(list.items[2].foo === 'bar'); - }); - }); - - describe('addItem', function() { - beforeEach(function() { - list = new List(); - }); - - it('should add items to a list', function() { - list.addItem('a', {content: '...'}); - list.addItem('b', {content: '...'}); - list.addItem('c', {content: '...'}); - assert(list.items.length === 3); - }); - }); - - describe('removeItem', function() { - beforeEach(function() { - list = new List(); - }); - - it('should remove an item from `items`', function() { - list.addItem('a', {content: '...'}); - list.addItem('b', {content: '...'}); - list.addItem('c', {content: '...'}); - assert(list.items.length === 3); - var a = list.getItem('a'); - list.removeItem(a); - assert(list.items.length === 2); - var c = list.getItem(c); - list.removeItem(c); - assert(list.items[0].key === 'b'); - }); - - it('should remove an item from `items` by key', function() { - list.addItem('a', {content: '...'}); - list.addItem('b', {content: '...'}); - list.addItem('c', {content: '...'}); - assert(list.items.length === 3); - list.removeItem('c'); - assert(list.items.length === 2); - list.removeItem('b'); - assert(list.items[0].key === 'a'); - }); - }); - - describe('addItems', function() { - beforeEach(function() { - list = new List(); - }); - - it('should add an object with multiple items', function() { - list.addItems({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.items[1].contents)); - }); - - it('should signal `loaded` when finished (addItems)', function() { - list.on('addItems', function(items) { - for (var key in items) { - if (key === 'c') { - list.loaded = true; - break; - } - list.addItem('foo/' + key, items[key]); - } - }); - - list.addItems({ - a: {path: 'a.txt'}, - b: {path: 'b.txt'}, - c: {path: 'c.txt'} - }); - - assert.equal(list.items.length, 2); - assert.equal(list.items[0].key, 'foo/a'); - assert.equal(list.items[0].path, 'a.txt'); - }); - }); - - describe('addList', function() { - beforeEach(function() { - list = new List(); - }); - - it('should add an array with multiple items', function() { - list.addList([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.items[1].contents)); - }); - - it('should take a callback on `addList`', function() { - function addContents(item) { - item.contents = new Buffer(item.path.charAt(0)); - } - - list.addList([ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } } - ], addContents); - - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.items[1].contents)); - assert(isBuffer(list.items[2].contents)); - }); - - it('should throw an error when the list is not an array', function() { - function addContents(item) { - item.contents = new Buffer(item.path.charAt(0)); - } - - (function() { - list.addList({ - 'a.md': {locals: { date: '2014-01-01', foo: 'zzz', bar: 1 }}, - 'f.md': {locals: { date: '2014-01-01', foo: 'mmm', bar: 2 }}, - 'd.md': {locals: { date: '2014-01-01', foo: 'xxx', bar: 3 }} - }, addContents); - - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.items[1].contents)); - assert(isBuffer(list.items[2].contents)); - }).should.throw('expected list to be an array.'); - }); - - it('should signal `loaded` when finished (addList)', function() { - list.on('addList', function(items) { - var len = items.length; - var i = -1; - - while (++i < len) { - if (items[i].path === 'd.md') { - list.loaded = true; - break; - } - list.addItem('foo/' + items[i].path, items[i]); - } - }); - - list.addList([ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } } - ]); - - assert.equal(list.items.length, 2); - assert.equal(list.keys.indexOf('d.md'), -1); - }); - }); - - describe('queue', function() { - beforeEach(function() { - list = new List(); - }); - - it('should emit arguments on addItem', function(done) { - list.on('addItem', function(args) { - assert(args[0] === 'a'); - assert(args[1] === 'b'); - assert(args[2] === 'c'); - assert(args[3] === 'd'); - assert(args[4] === 'e'); - done(); - }); - - list.addItem('a', 'b', 'c', 'd', 'e'); - }); - - it('should expose the `queue` property for loading items', function() { - list.queue.push(list.item('b', {path: 'b'})); - - list.addItem('a', {path: 'a'}); - assert(list.items[0].key === 'a'); - assert(list.items[1].key === 'b'); - }); - - it('should load all items on the queue when addItem is called', function() { - list.on('addItem', function(args) { - var len = args.length; - var last = args[len - 1]; - if (typeof last === 'string') { - args[len - 1] = { content: last }; - } - }); - - list.addItem('a.html', 'aaa'); - list.addItem('b.html', 'bbb'); - list.addItem('c.html', 'ccc'); - - assert(list.items[0].path === 'a.html'); - assert(list.getItem('a.html').content === 'aaa'); - assert(list.items[1].path === 'b.html'); - assert(list.getItem('b.html').content === 'bbb'); - assert(list.items[2].path === 'c.html'); - assert(list.getItem('c.html').content === 'ccc'); - }); - }); - - describe('sortBy', function() { - var items = [ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { path: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { path: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { path: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { path: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { path: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { path: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { path: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { path: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { path: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { path: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } } - ]; - - it('should sort a list', function() { - list = new List(); - list.addList(items); - - var compare = function(prop) { - return function(a, b, fn) { - var valA = get(a, prop); - var valB = get(b, prop); - return fn(valA, valB); - }; - }; - - var res = list.sortBy('locals.date', 'doesnt.exist', [ - compare('locals.foo'), - compare('locals.bar') - ]); - - assert.containEql(res.items, [ - { key: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { key: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { key: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { key: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { key: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { key: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { key: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { key: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { key: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { key: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } }, - { key: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { key: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { key: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } } - ]); - }); - - it('should not sort the (original) instance list `items`', function() { - list = new List(); - list.addList(items); - - var compare = function(prop) { - return function(a, b, fn) { - var valA = get(a, prop); - var valB = get(b, prop); - return fn(valA, valB); - }; - }; - - var res = list.sortBy('locals.date', 'doesnt.exist', [ - compare('locals.foo'), - compare('locals.bar') - ]); - - // should not be sorted - assert.containEql(list.items, items); - - // should be sorted - assert.containEql(res.items, [ - { key: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { key: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { key: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { key: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { key: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { key: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { key: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { key: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { key: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { key: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } }, - { key: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { key: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { key: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } } - ]); - }); - - it('should pass options to array-sort from the constructor', function() { - list = new List({sort: {reverse: true}}); - list.addList(items); - - var compare = function(prop) { - return function(a, b, fn) { - var valA = get(a, prop); - var valB = get(b, prop); - return fn(valA, valB); - }; - }; - - var res = list.sortBy('locals.date', 'doesnt.exist', [ - compare('locals.foo'), - compare('locals.bar') - ]); - - assert.containEql(res.items, [ - { key: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { key: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { key: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { key: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } }, - { key: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { key: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { key: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { key: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { key: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { key: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { key: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { key: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { key: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } } - ]); - }); - - it('should pass options to array-sort from the sortBy method', function() { - list = new List(); - list.addList(items); - - var compare = function(prop) { - return function(a, b, fn) { - var valA = get(a, prop); - var valB = get(b, prop); - return fn(valA, valB); - }; - }; - - var res = list.sortBy('locals.date', 'doesnt.exist', [ - compare('locals.foo'), - compare('locals.bar') - ], {reverse: true}); - - assert.containEql(res.items, [ - { key: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { key: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { key: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { key: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } }, - { key: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { key: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { key: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { key: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { key: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { key: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { key: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { key: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { key: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } } - ]); - }); - }); - - describe('groupBy', function() { - var items = [ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { path: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { path: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { path: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { path: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { path: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { path: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { path: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { path: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { path: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { path: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } } - ]; - - it('should group a list by a property', function() { - list = new List(); - list.addList(items); - - var res = list.groupBy('locals.foo'); - var keys = ['zzz', 'mmm', 'xxx', 'aaa', 'ccc', 'rrr', 'ttt', 'yyy']; - assert.deepEqual(Object.keys(res), keys); - }); - }); - - describe('sort and group', function() { - var items = [ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2013-01-01', foo: 'xxx', bar: 3 } }, - { path: 'i.md', locals: { date: '2013-02-01', foo: 'xxx', bar: 5 } }, - { path: 'i.md', locals: { date: '2013-02-01', foo: 'lll', bar: 5 } }, - { path: 'k.md', locals: { date: '2013-03-01', foo: 'xxx', bar: 1 } }, - { path: 'j.md', locals: { date: '2013-02-01', foo: 'xxx', bar: 4 } }, - { path: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { path: 'm.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { path: 'n.md', locals: { date: '2013-01-01', foo: 'xxx', bar: 7 } }, - { path: 'o.md', locals: { date: '2013-01-01', foo: 'xxx', bar: 7 } }, - { path: 'p.md', locals: { date: '2013-01-01', foo: 'xxx', bar: 7 } }, - { path: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { path: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { path: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { path: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { path: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } } - ]; - - it('should group a list by a property', function() { - list = new List(items); - - var context = list - .sortBy('locals.date') - .groupBy(function(view) { - var date = view.locals.date; - view.locals.year = date.slice(0, 4); - view.locals.month = date.slice(5, 7); - view.locals.day = date.slice(8, 10); - return view.locals.year; - }, 'locals.month'); - - var keys = Object.keys(context); - assert(keys[0] === '2012'); - assert(keys[1] === '2013'); - assert(keys[2] === '2014'); - assert(keys[3] === '2015'); - }); - }); - - describe('paginate', function() { - var items = [ - { path: 'a.md', locals: { date: '2014-01-01', foo: 'zzz', bar: 1 } }, - { path: 'f.md', locals: { date: '2014-01-01', foo: 'mmm', bar: 2 } }, - { path: 'd.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 3 } }, - { path: 'i.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 5 } }, - { path: 'k.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 1 } }, - { path: 'j.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 4 } }, - { path: 'h.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 6 } }, - { path: 'l.md', locals: { date: '2014-01-01', foo: 'xxx', bar: 7 } }, - { path: 'e.md', locals: { date: '2015-01-02', foo: 'aaa', bar: 8 } }, - { path: 'b.md', locals: { date: '2012-01-02', foo: 'ccc', bar: 9 } }, - { path: 'f.md', locals: { date: '2014-06-01', foo: 'rrr', bar: 10 } }, - { path: 'c.md', locals: { date: '2015-04-12', foo: 'ttt', bar: 11 } }, - { path: 'g.md', locals: { date: '2014-02-02', foo: 'yyy', bar: 12 } } - ]; - - it('should paginate a list', function() { - list = new List(items); - - var res = list.paginate(); - assert.equal(res.length, 2); - assert.containEql(res[0].items, items.slice(0, 10)); - assert.containEql(res[1].items, items.slice(10)); - }); - - it('should add pager properties', function() { - list = new List({pager: true}); - list.addList(items); - list.items.forEach(function(item, i) { - assert.equal(item.data.pager.index, i); - }); - }); - - it('should paginate a list with given options', function() { - list = new List(items); - var res = list.paginate({limit: 5}); - - assert.equal(res.length, 3); - assert.containEql(res[0].items, items.slice(0, 5)); - assert.containEql(res[1].items, items.slice(5, 10)); - assert.containEql(res[2].items, items.slice(10)); - }); - }); - - describe('Views instance', function() { - beforeEach(function() { - views = new Views(); - }); - - it('should add views from an instance of Views', function() { - views.addViews({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - - list = new List(views); - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.items[1].contents)); - }); - }); - - describe('getIndex', function() { - beforeEach(function() { - list = new List(); - }); - it('should get the index of a key when key is not renamed', function() { - list.addItem('a/b/c/ddd.hbs', {content: 'ddd'}); - list.addItem('a/b/c/eee.hbs', {content: 'eee'}); - assert(list.getIndex('a/b/c/ddd.hbs') === 0); - assert(list.getIndex('a/b/c/eee.hbs') === 1); - }); - - it('should get the index of a key when key is renamed', function() { - list = new List({ - renameKey: function(key) { - return path.basename(key); - } - }); - list.addItem('a/b/c/ddd.hbs', {content: 'ddd'}); - list.addItem('a/b/c/eee.hbs', {content: 'eee'}); - assert(list.getIndex('a/b/c/ddd.hbs') === 0); - assert(list.getIndex('ddd.hbs') === 0); - assert(list.getIndex('a/b/c/eee.hbs') === 1); - assert(list.getIndex('eee.hbs') === 1); - }); - }); - - describe('getItem', function() { - beforeEach(function() { - list = new List(); - }); - - it('should get an view from `views`', function() { - list.addItem('one', {content: 'aaa'}); - list.addItem('two', {content: 'zzz'}); - assert(list.items.length === 2); - assert(isBuffer(list.items[0].contents)); - assert(isBuffer(list.getItem('one').contents)); - assert(list.getItem('one').contents.toString() === 'aaa'); - assert(list.getItem('two').contents.toString() === 'zzz'); - }); - }); - - describe('use', function() { - beforeEach(function() { - list = new List(); - }); - - it('should use middleware on a list', function() { - list.addItem('one', {content: 'aaa'}); - list.addItem('two', {content: 'zzz'}); - - list - .use(function() { - this.set('foo', 'bar'); - }) - .use(function() { - this.set('one', 'two'); - }); - - assert(list.one === 'two'); - assert(list.foo === 'bar'); - }); - }); -}); - diff --git a/vendors/update/test/list.render.js b/vendors/update/test/list.render.js deleted file mode 100644 index 7b226a88..00000000 --- a/vendors/update/test/list.render.js +++ /dev/null @@ -1,137 +0,0 @@ -require('mocha'); -require('should'); -var async = require('async'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var pages; - -describe('render', function() { - describe('rendering', function() { - beforeEach(function() { - pages = new List(); - pages.engine('tmpl', require('engine-base')); - }); - - it('should throw an error when no callback is given:', function() { - (function() { - pages.render({}); - }).should.throw('List#render is async and expects a callback function'); - }); - - it('should throw an error when an engine is not defined:', function(done) { - pages.addItem('foo.bar', {content: '<%= name %>'}); - var page = pages.getItem('foo.bar'); - - pages.render(page, function(err) { - assert(err.message === 'List#render cannot find an engine for: .bar'); - done(); - }); - }); - - it('should use helpers to render a item:', function(done) { - var locals = {name: 'Halle'}; - - pages.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - pages.addItem('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getItem('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - - assert(res.content === 'a HALLE b'); - done(); - }); - }); - - it('should use helpers when rendering a item:', function(done) { - var locals = {name: 'Halle'}; - pages.helper('upper', function(str) { - return str.toUpperCase(str); - }); - - pages.addItem('a.tmpl', {content: 'a <%= upper(name) %> b', locals: locals}); - var page = pages.getItem('a.tmpl'); - - pages.render(page, function(err, res) { - if (err) return done(err); - assert(res.content === 'a HALLE b'); - done(); - }); - }); - - it('should render a template when contents is a buffer:', function(done) { - pages.addItem('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var item = pages.getItem('a.tmpl'); - - pages.render(item, function(err, item) { - if (err) return done(err); - assert(item.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a template when content is a string:', function(done) { - pages.addItem('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - var item = pages.getItem('a.tmpl'); - - pages.render(item, function(err, item) { - if (err) return done(err); - assert(item.contents.toString() === 'b'); - done(); - }); - }); - - it('should render a item from its path:', function(done) { - pages.addItem('a.tmpl', {content: '<%= a %>', locals: {a: 'b'}}); - - pages.render('a.tmpl', function(err, item) { - if (err) return done(err); - assert(item.content === 'b'); - done(); - }); - }); - - it('should use a plugin for rendering:', function(done) { - pages.engine('tmpl', require('engine-base')); - pages.option('engine', 'tmpl'); - - pages.addItems({ - 'a': {content: '<%= title %>', locals: {title: 'aaa'}}, - 'b': {content: '<%= title %>', locals: {title: 'bbb'}}, - 'c': {content: '<%= title %>', locals: {title: 'ccc'}}, - 'd': {content: '<%= title %>', locals: {title: 'ddd'}}, - 'e': {content: '<%= title %>', locals: {title: 'eee'}}, - 'f': {content: '<%= title %>', locals: {title: 'fff'}}, - 'g': {content: '<%= title %>', locals: {title: 'ggg'}}, - 'h': {content: '<%= title %>', locals: {title: 'hhh'}}, - 'i': {content: '<%= title %>', locals: {title: 'iii'}}, - 'j': {content: '<%= title %>', locals: {title: 'jjj'}} - }); - - pages.use(function(collection) { - collection.option('pager', false); - - collection.renderEach = function(cb) { - var list = new List(collection); - - async.map(list.items, function(item, next) { - collection.render(item, next); - }, cb); - }; - }); - - pages.renderEach(function(err, items) { - if (err) return done(err); - assert(items[0].content === 'aaa'); - assert(items[9].content === 'jjj'); - assert(items.length === 10); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/list.use.js b/vendors/update/test/list.use.js deleted file mode 100644 index 5ac2c1b9..00000000 --- a/vendors/update/test/list.use.js +++ /dev/null @@ -1,156 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var List = App.List; -var Item = App.Item; -var list; - -describe('list.use', function() { - beforeEach(function() { - list = new List(); - }); - - it('should expose the instance to `use`:', function(done) { - list.use(function(inst) { - assert(inst instanceof List); - done(); - }); - }); - - it('should be chainable:', function(done) { - list.use(function(inst) { - assert(inst instanceof List); - }) - .use(function(inst) { - assert(inst instanceof List); - }) - .use(function(inst) { - assert(inst instanceof List); - done(); - }); - }); - - it('should expose the list to a plugin:', function() { - list.use(function(items) { - assert(items instanceof List); - items.foo = items.addItem.bind(items); - }); - - list.foo('a', {content: '...'}); - assert(list.hasItem('a')); - }); - - it('should expose list when chained:', function() { - list - .use(function(items) { - assert(items instanceof List); - items.foo = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof List); - items.bar = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof List); - items.baz = items.addItem.bind(items); - }); - - var pages = list; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(list.hasItem('a')); - assert(list.hasItem('b')); - assert(list.hasItem('c')); - }); - - it('should work when a custom `Item` constructor is passed:', function() { - list = new List({Item: require('vinyl')}); - list - .use(function(items) { - assert(items instanceof List); - items.foo = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof List); - items.bar = items.addItem.bind(items); - }) - .use(function(items) { - assert(items instanceof List); - items.baz = items.addItem.bind(items); - }); - - var pages = list; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(list.hasItem('a')); - assert(list.hasItem('b')); - assert(list.hasItem('c')); - }); - - it('should pass to item `use` if a function is returned:', function() { - list.use(function(items) { - assert(items instanceof List); - - return function(item) { - item.foo = items.addItem.bind(items); - assert(item.isItem || item.isView); - }; - }); - - list.addItem('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .foo({path: 'c', content: '...'}) - .foo({path: 'd', content: '...'}); - - assert(list.hasItem('a')); - assert(list.hasItem('b')); - assert(list.hasItem('c')); - assert(list.hasItem('d')); - }); - - it('should be chainable when a item function is returned:', function() { - list - .use(function(items) { - assert(items instanceof List); - - return function(item) { - item.foo = items.addItem.bind(items); - assert(item instanceof Item); - }; - }) - .use(function(items) { - assert(items instanceof List); - - return function(item) { - item.bar = items.addItem.bind(items); - assert(item instanceof Item); - }; - }) - .use(function(items) { - assert(items instanceof List); - - return function(item) { - item.baz = items.addItem.bind(items); - assert(item instanceof Item); - }; - }); - - list.addItem('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .bar({path: 'c', content: '...'}) - .baz({path: 'd', content: '...'}); - - assert(list.hasItem('a')); - assert(list.hasItem('b')); - assert(list.hasItem('c')); - assert(list.hasItem('d')); - }); -}); diff --git a/vendors/update/test/mergePartials.js b/vendors/update/test/mergePartials.js deleted file mode 100644 index 38f23be1..00000000 --- a/vendors/update/test/mergePartials.js +++ /dev/null @@ -1,104 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('mergePartials', function() { - beforeEach(function() { - app = new App(); - }); - - it('should merge multiple partials collections onto one collection:', function() { - var opts = { viewType: 'partial' }; - app.create('foo', opts); - app.create('bar', opts); - app.create('baz', opts); - - app.foo('a', {path: 'a', content: 'aaa'}); - app.bar('b', {path: 'b', content: 'bbb'}); - app.baz('c', {path: 'c', content: 'ccc'}); - - var actual = app.mergePartials(); - actual.should.have.property('partials'); - actual.partials.should.have.properties(['a', 'b', 'c']); - }); - - it('should keep partials collections on separaet collections:', function() { - var opts = { viewType: 'partial' }; - app.create('foo', opts); - app.create('bar', opts); - app.create('baz', opts); - - app.foo('a', {path: 'a', content: 'aaa'}); - app.bar('b', {path: 'b', content: 'bbb'}); - app.baz('c', {path: 'c', content: 'ccc'}); - - var actual = app.mergePartials({mergePartials: false}); - actual.should.not.have.property('partials'); - actual.should.eql({ foos: { a: 'aaa' }, bars: { b: 'bbb' }, bazs: { c: 'ccc' } }); - }); - - it('should emit `mergePartials`:', function() { - var opts = { viewType: 'partial' }; - app.create('foo', opts); - app.create('bar', opts); - app.create('baz', opts); - var arr = []; - - app.on('onMerge', function(view) { - arr.push(view.content); - }); - - app.foo('a', {path: 'a', content: 'aaa'}); - app.bar('b', {path: 'b', content: 'bbb'}); - app.baz('c', {path: 'c', content: 'ccc'}); - - var actual = app.mergePartials({mergePartials: false}); - actual.should.not.have.property('partials'); - actual.should.eql({ foos: { a: 'aaa' }, bars: { b: 'bbb' }, bazs: { c: 'ccc' } }); - arr.should.eql(['aaa', 'bbb', 'ccc']); - }); - - it('should handle `onMerge` middleware:', function() { - var opts = { viewType: 'partial' }; - app.create('foo', opts); - app.create('bar', opts); - app.create('baz', opts); - - app.onMerge(/./, function(view, next) { - view.content += ' onMerge'; - next(); - }); - - app.foo('a', {path: 'a', content: 'aaa'}); - app.bar('b', {path: 'b', content: 'bbb'}); - app.baz('c', {path: 'c', content: 'ccc'}); - - var actual = app.mergePartials({mergePartials: false}); - actual.should.eql({ - foos: {a: 'aaa onMerge'}, - bars: {b: 'bbb onMerge'}, - bazs: {c: 'ccc onMerge'} - }); - }); - - it('should skip views with `nomerge=true`:', function() { - var opts = { viewType: 'partial' }; - - app.create('foo', opts); - app.create('bar', opts); - app.create('baz', opts); - - app.onMerge(/[ab]/, function(view, next) { - view.options.nomerge = true; - next(); - }); - - app.foo('a', {path: 'a', content: 'aaa'}); - app.bar('b', {path: 'b', content: 'bbb'}); - app.baz('c', {path: 'c', content: 'ccc'}); - - var actual = app.mergePartials({mergePartials: false}); - actual.should.eql({ bazs: { c: 'ccc' } }); - }); -}); diff --git a/vendors/update/test/partials.js b/vendors/update/test/partials.js deleted file mode 100644 index b5fbb94c..00000000 --- a/vendors/update/test/partials.js +++ /dev/null @@ -1,202 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app, pages; - -describe('partials', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.engine('hbs', require('engine-handlebars')); - - app.create('partials', { viewType: 'partial' }); - app.create('include', { viewType: 'partial' }); - app.create('layouts', { viewType: 'layout' }); - pages = app.create('page'); - }); - - it('should inject a partial with a helper:', function(done) { - app.include('base', {path: 'base.tmpl', content: 'xyz'}); - app.pages('a.tmpl', {path: 'a.tmpl', content: 'a <%= include("base") %> c'}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a xyz c'); - done(); - }); - }); - - it('should inject a partial with a helper on a collection:', function(done) { - app.include('base', {path: 'base.tmpl', content: 'xyz'}); - pages.engine('.tmpl', require('engine-handlebars')); - pages.helpers(app._.helpers.sync); - pages.asyncHelpers(app._.helpers.async); - pages.addView('a.tmpl', {path: 'a.tmpl', content: 'a {{include "base" }} c'}); - var page = pages.getView('a.tmpl'); - - pages.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a xyz c'); - done(); - }); - }); - - it('should use handlebars partial with a helper on a collection:', function(done) { - app.include('base', {path: 'base.tmpl', content: 'xyz'}); - pages.engine('.tmpl', require('engine-handlebars')); - pages.helpers(app._.helpers.sync); - pages.asyncHelpers(app._.helpers.async); - pages.addView('a.tmpl', {path: 'a.tmpl', content: 'a {{> base }} c'}); - - var page = pages.getView('a.tmpl'); - var locals = app.mergePartials(this.options); - - pages.render(page, locals, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a xyz c'); - done(); - }); - }); - - it('should use layouts with partials:', function(done) { - app.layout('default', {path: 'a.tmpl', content: 'a {% body %} c'}); - app.include('b', {path: 'b.tmpl', content: 'b', layout: 'default'}); - app.pages('a.tmpl', {path: 'c.tmpl', content: '<%= include("b") %>'}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a b c'); - done(); - }); - }); - - it('should add `layoutApplied` after layout is applied:', function(done) { - app.layout('default', {path: 'a.tmpl', content: 'a {% body %} c'}); - app.include('b', {path: 'b.tmpl', content: 'b', layout: 'default'}); - app.pages('a.tmpl', {path: 'c.tmpl', content: '<%= include("b") %>'}); - var page = app.pages.getView('a.tmpl'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(app.layouts.getView('default').options.layoutApplied); - assert.equal(view.content, 'a b c'); - done(); - }); - }); - - it('should pass partials to handlebars:', function(done) { - app.onMerge(/\.hbs$/, function(view, next) { - app.applyLayout(view); - next(); - }); - - app.layout('default', {path: 'a.hbs', content: 'a {% body %} c'}); - app.include('foo', {path: 'foo.hbs', content: 'foo', layout: 'default'}); - app.pages('a.hbs', {path: 'c.hbs', content: '{{> foo }}'}); - var page = app.pages.getView('a.hbs'); - - app.render(page, function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a foo c'); - done(); - }); - }); - - it('should only merge in the specified viewTypes:', function(done) { - app.onMerge(/\.hbs$/, function(view, next) { - app.applyLayout(view); - next(); - }); - - app.layout('default', {path: 'a.hbs', content: 'a {% body %} c'}); - app.option('mergeTypes', ['includes']); - - app.partial('foo', {path: 'bar.hbs', content: 'bar', layout: 'default'}); - app.include('foo', {path: 'foo.hbs', content: 'foo', layout: 'default'}); - - app.pages('a.hbs', {path: 'c.hbs', content: '{{> foo }}'}); - app.pages.getView('a.hbs') - .render(function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a foo c'); - done(); - }); - - }); - - it('should merge the specified viewTypes in the order defined:', function(done) { - app.onMerge(/\.hbs$/, function(view, next) { - app.applyLayout(view); - next(); - }); - - app.layout('default', {path: 'a.hbs', content: 'a {% body %} c'}); - app.option('mergeTypes', ['includes', 'partials']); - - app.partial('foo', {path: 'bar.hbs', content: 'bar', layout: 'default'}); - app.include('foo', {path: 'foo.hbs', content: 'foo', layout: 'default'}); - - app.pages('a.hbs', {path: 'c.hbs', content: '{{> foo }}'}); - app.pages.getView('a.hbs') - .render(function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a bar c'); - done(); - }); - }); - - it('should not merge in partials with `options.nomerge` defined:', function(done) { - app.onMerge(/\.hbs$/, function(view, next) { - app.applyLayout(view); - next(); - }); - - app.layout('default', {path: 'a.hbs', content: 'a {% body %} c'}); - app.option('mergeTypes', ['includes', 'partials']); - - app.partial('foo', {path: 'bar.hbs', content: 'bar', layout: 'default', options: {nomerge: true}}); - app.include('foo', {path: 'foo.hbs', content: 'foo', layout: 'default'}); - - app.pages('a.hbs', {path: 'c.hbs', content: '{{> foo }}'}); - app.pages.getView('a.hbs') - .render(function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a foo c'); - done(); - }); - }); - - it('should emit an `onMerge` event:', function(done) { - app.on('onMerge', function(view) { - app.applyLayout(view); - }); - - app.layout('default', {path: 'a.hbs', content: 'a {% body %} c'}); - app.option('mergeTypes', ['includes', 'partials']); - - app.partial('foo', {path: 'bar.hbs', content: 'bar', layout: 'default'}); - app.include('foo', {path: 'foo.hbs', content: 'foo', layout: 'default'}); - - app.pages('a.hbs', {path: 'c.hbs', content: '{{> foo }}'}); - app.pages.getView('a.hbs') - .render(function(err, view) { - if (err) return done(err); - assert.equal(typeof view.content, 'string'); - assert.equal(view.content, 'a bar c'); - done(); - }); - }); -}); diff --git a/vendors/update/test/questions.js b/vendors/update/test/questions.js deleted file mode 100644 index 4318e643..00000000 --- a/vendors/update/test/questions.js +++ /dev/null @@ -1,58 +0,0 @@ -require('mocha'); -require('should'); -var fs = require('fs'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe.skip('content', function() { - beforeEach(function() { - app = new App(); - }); - - it('should store a question:', function() { - app.question('a', 'b'); - assert(app.questions); - assert(app.questions.cache); - assert(app.questions.cache.a); - assert(app.questions.cache.a.name === 'a'); - assert(app.questions.cache.a.message === 'b'); - }); - - it('should ask a question and use data value to answer:', function(done) { - app.question('a', 'b'); - app.data('a', 'b'); - - app.ask('a', function(err, answer) { - assert(!err); - assert(answer); - assert(answer === 'b'); - done(); - }) - }); - - it('should ask a question and use store value to answer:', function(done) { - app.question('a', 'b'); - app.store.set('a', 'c'); - - app.ask('a', function(err, answer) { - assert(!err); - assert(answer); - assert(answer === 'c'); - done(); - }) - }); - - it('should ask a question and use config value to answer:', function(done) { - app.question('a', 'b'); - app.store.set('a', 'c'); - - app.ask('a', function(err, answer) { - assert(!err); - assert(answer); - assert(answer === 'c'); - done(); - }) - }); -}); diff --git a/vendors/update/test/renameKey.js b/vendors/update/test/renameKey.js deleted file mode 100644 index 94b3ab2b..00000000 --- a/vendors/update/test/renameKey.js +++ /dev/null @@ -1,350 +0,0 @@ -var path = require('path'); -var support = require('./support'); -var App = support.resolve(); -var app; - -function renameKey(key) { - return path.basename(key, path.extname(key)); -} - -describe('renameKey', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('pages'); - app.create('posts'); - }); - - describe('global options:', function() { - it('should use `renameKey` function defined on global opts:', function() { - app.option('renameKey', renameKey); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.posts('a/b/c/c.txt', {content: '...'}); - app.post('a/b/c/d.txt', {content: '...'}); - app.post('a/b/c/e.txt', {content: '...'}); - - app.views.posts.should.have.property('a'); - app.views.posts.should.have.property('b'); - app.views.posts.should.have.property('c'); - app.views.posts.should.have.property('d'); - app.views.posts.should.have.property('e'); - }); - - it('should not have conflicts when view name is the collection name:', function() { - app.option('renameKey', renameKey); - - app.post('a/b/c/post.txt', {content: 'this is contents'}); - app.page('a/b/c/page.txt', {content: 'this is contents'}); - - app.views.posts.should.have.property('post'); - app.views.pages.should.have.property('page'); - }); - }); - - describe('create method:', function() { - it('should use `renameKey` option chained from the `create` method:', function() { - app.create('post') - .option('renameKey', function(key) { - return 'posts/' + path.basename(key); - }); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.posts('a/b/c/c.txt', {content: '...'}); - app.post('a/b/c/d.txt', {content: '...'}); - app.post('a/b/c/e.txt', {content: '...'}); - - app.views.posts.should.have.property('posts/a.txt'); - app.views.posts.should.have.property('posts/b.txt'); - app.views.posts.should.have.property('posts/c.txt'); - app.views.posts.should.have.property('posts/d.txt'); - app.views.posts.should.have.property('posts/e.txt'); - }); - }); - - describe('create method:', function() { - it('should use `renameKey` defined on the `create` method:', function() { - app.create('post', { - renameKey: function(key) { - return 'posts/' + path.basename(key); - } - }); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.posts('a/b/c/c.txt', {content: '...'}); - app.post('a/b/c/d.txt', {content: '...'}); - app.post('a/b/c/e.txt', {content: '...'}); - - app.views.posts.should.have.property('posts/a.txt'); - app.views.posts.should.have.property('posts/b.txt'); - app.views.posts.should.have.property('posts/c.txt'); - app.views.posts.should.have.property('posts/d.txt'); - app.views.posts.should.have.property('posts/e.txt'); - }); - }); - - describe('collections:', function() { - describe('setting:', function() { - it('should get a view with the `renameKey` defined on app.options:', function() { - app.option('renameKey', function(key) { - return 'foo/' + path.basename(key); - }); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.post('a/b/c/c.txt', {content: '...'}); - - app.views.posts.should.have.property('foo/a.txt'); - app.views.posts.should.have.property('foo/b.txt'); - app.views.posts.should.have.property('foo/c.txt'); - }); - - it('should use `renameKey` defined on collection.options:', function() { - app.pages.option('renameKey', function(key) { - return 'page/' + path.basename(key); - }); - - app.posts.option('renameKey', function(key) { - return 'post/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.posts('a/b/c/c.txt', {content: '...'}); - app.post('a/b/c/d.txt', {content: '...'}); - app.post('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('page/a.txt'); - app.views.pages.should.have.property('page/b.txt'); - app.views.pages.should.have.property('page/c.txt'); - app.views.pages.should.have.property('page/d.txt'); - app.views.pages.should.have.property('page/e.txt'); - - app.views.posts.should.have.property('post/a.txt'); - app.views.posts.should.have.property('post/b.txt'); - app.views.posts.should.have.property('post/c.txt'); - app.views.posts.should.have.property('post/d.txt'); - app.views.posts.should.have.property('post/e.txt'); - }); - - it('should use the `collection.renameKey()` method:', function() { - app.pages.renameKey(function(key) { - return 'baz/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('baz/a.txt'); - app.views.pages.should.have.property('baz/b.txt'); - app.views.pages.should.have.property('baz/c.txt'); - app.views.pages.should.have.property('baz/d.txt'); - app.views.pages.should.have.property('baz/e.txt'); - }); - - it('should use the `app.renameKey()` method:', function() { - app.renameKey(function(key) { - return 'app/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('app/a.txt'); - app.views.pages.should.have.property('app/b.txt'); - app.views.pages.should.have.property('app/c.txt'); - app.views.pages.should.have.property('app/d.txt'); - app.views.pages.should.have.property('app/e.txt'); - }); - - it('should prefer collection method over app.options:', function() { - // this works when you switch the order around... - app.pages.renameKey(function pagesRenameKey(key) { - return 'aaa/' + path.basename(key); - }); - app.option('renameKey', function optsRenameKey(key) { - return 'foo/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('aaa/a.txt'); - app.views.pages.should.have.property('aaa/b.txt'); - app.views.pages.should.have.property('aaa/c.txt'); - app.views.pages.should.have.property('aaa/d.txt'); - app.views.pages.should.have.property('aaa/e.txt'); - }); - - it('should prefer collection method over app method:', function() { - app.pages.renameKey(function(key) { - return 'aaa/' + path.basename(key); - }); - app.renameKey(function(key) { - return 'zzz/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('aaa/a.txt'); - app.views.pages.should.have.property('aaa/b.txt'); - app.views.pages.should.have.property('aaa/c.txt'); - app.views.pages.should.have.property('aaa/d.txt'); - app.views.pages.should.have.property('aaa/e.txt'); - }); - - it('should prefer collection options over app.options:', function() { - app.pages.option('renameKey', function(key) { - return 'collection/' + path.basename(key); - }); - app.option('renameKey', function(key) { - return 'app/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('collection/a.txt'); - app.views.pages.should.have.property('collection/b.txt'); - app.views.pages.should.have.property('collection/c.txt'); - app.views.pages.should.have.property('collection/d.txt'); - app.views.pages.should.have.property('collection/e.txt'); - }); - - it('should prefer collection options over app method:', function() { - app.pages.option('renameKey', function(key) { - return 'collection/' + path.basename(key); - }); - app.renameKey(function(key) { - return 'app/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.pages('a/b/c/c.txt', {content: '...'}); - app.page('a/b/c/d.txt', {content: '...'}); - app.page('a/b/c/e.txt', {content: '...'}); - - app.views.pages.should.have.property('collection/a.txt'); - app.views.pages.should.have.property('collection/b.txt'); - app.views.pages.should.have.property('collection/c.txt'); - app.views.pages.should.have.property('collection/d.txt'); - app.views.pages.should.have.property('collection/e.txt'); - }); - - it('should use renameKey on chained methods:', function() { - app.page('test/fixtures/pages/a.txt', { - options: { - renameKey: function foo(key) { - return 'foo/' + path.basename(key); - } - } - }); - - app.page('test/fixtures/pages/a.hbs', { - options: { - renameKey: function bar(key) { - return 'bar/' + path.basename(key); - } - } - }); - - app.views.pages.should.have.properties([ - 'foo/a.txt', - 'bar/a.hbs' - ]); - }); - }); - - describe('getting', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('post'); - app.create('page'); - }); - - it('should get a view with the `renameKey` defined on the `create` method:', function() { - app.create('post', { - renameKey: function createRenameKey(key) { - return 'posts/' + path.basename(key); - } - }); - - app.posts('a/b/c/a.txt', {content: '...'}); - app.posts('a/b/c/b.txt', {content: '...'}); - app.post('a/b/c/c.txt', {content: '...'}); - - app.posts.getView('a.txt').should.have.property('path', 'a/b/c/a.txt'); - app.posts.getView('posts/a.txt').should.have.property('path', 'a/b/c/a.txt'); - }); - - it('should get a view with `renameKey` on collection.options:', function() { - app.pages.option('renameKey', function(key) { - return 'bar/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.page('a/b/c/c.txt', {content: '...'}); - - app.views.pages.should.have.property('bar/a.txt'); - app.views.pages.should.have.property('bar/b.txt'); - app.views.pages.should.have.property('bar/c.txt'); - }); - - it('should get a view with the the `app.renameKey()` method:', function() { - app.renameKey(function(key) { - return 'baz/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.page('a/b/c/c.txt', {content: '...'}); - - app.views.pages.should.have.property('baz/a.txt'); - app.views.pages.should.have.property('baz/b.txt'); - app.views.pages.should.have.property('baz/c.txt'); - }); - - it('should get a view with the the `collection.renameKey()` method:', function() { - app.pages.renameKey(function(key) { - return 'baz/' + path.basename(key); - }); - - app.pages('a/b/c/a.txt', {content: '...'}); - app.pages('a/b/c/b.txt', {content: '...'}); - app.page('a/b/c/c.txt', {content: '...'}); - - app.views.pages.should.have.property('baz/a.txt'); - app.views.pages.should.have.property('baz/b.txt'); - app.views.pages.should.have.property('baz/c.txt'); - }); - }); - }); -}); diff --git a/vendors/update/test/render.js b/vendors/update/test/render.js deleted file mode 100644 index 04540b62..00000000 --- a/vendors/update/test/render.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe.skip('render', function() { - describe('engine', function() { - var view; - - beforeEach(function() { - app = new App({silent: true}); - app.engine('tmpl', require('engine-base')); - app.create('page'); - view = {contents: new Buffer('a <%= name %> b'), locals: {name: 'Halle'}}; - }); - - it('should render a view from an object:', function(done) { - app.page('a.tmpl', view) - .render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a Halle b'); - done(); - }); - }); - - it('should throw an error when a variable is undefined:', function(done) { - delete view.locals.name; - - app.page('a.tmpl', view) - .render(function(err) { - assert(err.message === 'name is not defined'); - done(); - }); - }); - - it('should re-throw an error when rethrow is true:', function(done) { - delete view.locals.name; - - app = new App({rethrow: true, silent: true}); - app.engine('tmpl', require('engine-base')); - app.create('page'); - - app.page('a.tmpl', view) - .render(function(err) { - assert(err.message === 'name is not defined'); - done(); - }); - }); - - it('should emit a re-thrown error when rethrow is true:', function(done) { - delete view.locals.name; - - app = new App({rethrow: true, silent: false}); - app.engine('tmpl', require('engine-base')); - app.create('page'); - - app.on('error', function(err) { - assert(err.message === 'name is not defined'); - done(); - }); - - app.page('a.tmpl', view) - .render(function(err) { - assert(err.message === 'name is not defined'); - }); - }); - }); -}); diff --git a/vendors/update/test/routes.js b/vendors/update/test/routes.js deleted file mode 100644 index af66b938..00000000 --- a/vendors/update/test/routes.js +++ /dev/null @@ -1,98 +0,0 @@ -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -function append(str) { - return function(view, next) { - var content = view.contents.toString(); - view.contents = new Buffer(content + ' ' + str); - next(); - }; -} -function prepend(str) { - return function(view, next) { - var content = view.contents.toString(); - view.contents = new Buffer(str + ' ' + content); - next(); - }; -} - -describe('routes', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - describe('params', function() { - it('should call param function when routing', function(done) { - app.param('id', function(view, next, id) { - assert.equal(id, '123'); - next(); - }); - - app.all('/foo/:id/bar', function(view, next) { - assert.equal(view.options.params.id, '123'); - next(); - }); - - app.router.handle({ path: '/foo/123/bar' }, done); - }); - }); - - describe('onLoad middleware', function() { - it('should run when templates are loaded:', function() { - app.onLoad(/\.tmpl/, prepend('onLoad')); - app.pages('a.tmpl', { path: 'a.tmpl', content: '<%= name %>'}); - - var page = app.pages.getView('a.tmpl'); - page.contents.toString().should.equal('onLoad <%= name %>'); - }); - }); - - describe('preCompile middleware', function() { - it('should run before templates are compiled:', function() { - - }); - }); - - describe('postCompile middleware', function() { - it('should run after templates are compiled:', function() { - - }); - }); - - describe('preRender middleware', function() { - it('should run before templates are rendered:', function(done) { - app.preRender(/\.tmpl/, prepend('preRender')); - app.pages('a.tmpl', { path: 'a.tmpl', content: '<%= name %>', locals: {name: 'aaa'} }); - - var page = app.pages.getView('a.tmpl'); - page.contents.toString().should.equal('<%= name %>'); - - page.render({}, function(err, res) { - if (err) return done(err); - res.contents.toString().should.equal('preRender aaa'); - done(); - }); - }); - }); - - describe('postRender middleware', function() { - it('should run after templates are rendered:', function(done) { - app.postRender(/\.tmpl/, append('postRender')); - app.pages('a.tmpl', { path: 'a.tmpl', content: '<%= name %>', locals: {name: 'aaa' }}); - - var page = app.pages.getView('a.tmpl'); - page.contents.toString().should.equal('<%= name %>'); - - page.render({}, function(err, res) { - if (err) return done(err); - res.contents.toString().should.equal('aaa postRender'); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/store.js b/vendors/update/test/store.js deleted file mode 100644 index e75ec6e0..00000000 --- a/vendors/update/test/store.js +++ /dev/null @@ -1,243 +0,0 @@ -'use strict'; - -require('mocha'); -require('should'); -var fs = require('fs'); -var path = require('path'); -var Store = require('data-store'); -var assert = require('assert'); -var App = require('../'); -var app; - -describe('store', function() { - beforeEach(function() { - app = new App(); - }); - - afterEach(function(cb) { - app.store.del({force: true}); - app.store.data = {}; - cb(); - }); - - it('should create a store at the given `cwd`', function() { - app = new App({store: {cwd: __dirname + '/actual'}}); - app.store.set('foo', 'bar'); - assert(path.basename(app.store.path) === 'update.json'); - assert(app.store.data.hasOwnProperty('foo')); - assert(app.store.data.foo === 'bar'); - assert(fs.existsSync(path.join(__dirname, 'actual', 'update.json'))); - }); - - it('should create a store using the given `indent` value', function() { - app = new App({store: {cwd: __dirname + '/actual', indent: 0}}); - app.store.set('foo', 'bar'); - var contents = fs.readFileSync(path.join(__dirname, 'actual', 'update.json'), 'utf8'); - assert(contents === '{"foo":"bar"}'); - }); - - it('should set a value on the store', function() { - app.store.set('one', 'two'); - app.store.data.one.should.equal('two'); - }); - - it('should set an object', function() { - app.store.set({four: 'five', six: 'seven'}); - app.store.data.four.should.equal('five'); - app.store.data.six.should.equal('seven'); - }); - - it('should set a nested value', function() { - app.store.set('a.b.c.d', {e: 'f'}); - app.store.data.a.b.c.d.e.should.equal('f'); - }); - - it('should union a value onto an array on the store', function() { - app.store.union('one', 'two'); - app.store.data.one.should.eql(['two']); - }); - - it('should not union duplicate values', function() { - app.store.union('one', 'two'); - app.store.data.one.should.eql(['two']); - - app.store.union('one', ['two']); - app.store.data.one.should.eql(['two']); - }); - - it('should concat an existing array:', function() { - app.store.union('one', 'a'); - app.store.data.one.should.eql(['a']); - - app.store.union('one', ['b']); - app.store.data.one.should.eql(['a', 'b']); - - app.store.union('one', ['c', 'd']); - app.store.data.one.should.eql(['a', 'b', 'c', 'd']); - }); - - it('should return true if a key exists on the store', function() { - app.store.set('foo', 'bar'); - assert(app.store.has('foo')); - }); - - it('should return true when the value is null', function() { - app.store.set('baz', null); - assert(app.store.has('baz')); - }); - - it('should return false when the value is undefined', function() { - app.store.set('qux', undefined); - assert(!app.store.has('qux')); - }); - - it('should return true if a nested key exists on the store', function() { - app.store.set('a.b.c.d', {x: 'zzz'}); - app.store.set('a.b.c.e', {f: null}); - app.store.set('a.b.g.j', {k: undefined}); - - assert(!app.store.has('a.b.bar')); - assert(app.store.has('a.b.c.d')); - assert(app.store.has('a.b.c.d.x')); - assert(!app.store.has('a.b.c.d.z')); - assert(app.store.has('a.b.c.e')); - assert(app.store.has('a.b.c.e.f')); - assert(!app.store.has('a.b.c.e.z')); - assert(app.store.has('a.b.g.j')); - assert(!app.store.has('a.b.g.j.k')); - assert(!app.store.has('a.b.g.j.z')); - }); - - it('should return true if a key exists `.hasOwn()` on the store', function() { - app.store.set('foo', 'bar'); - app.store.set('baz', null); - app.store.set('qux', undefined); - - assert(app.store.hasOwn('foo')); - assert(!app.store.hasOwn('bar')); - assert(app.store.hasOwn('baz')); - assert(app.store.hasOwn('qux')); - }); - - it('should return true if a nested key exists `.hasOwn()` on the store', function() { - app.store.set('a.b.c.d', {x: 'zzz'}); - app.store.set('a.b.c.e', {f: null}); - app.store.set('a.b.g.j', {k: undefined}); - - assert(app.store.hasOwn('a.b.c.d')); - assert(app.store.hasOwn('a.b.c.d.x')); - assert(app.store.has('a.b.c.e.f')); - assert(app.store.hasOwn('a.b.c.e.f')); - assert(app.store.hasOwn('a.b.g.j.k')); - - assert(!app.store.hasOwn('a.b.bar')); - assert(!app.store.hasOwn('a.b.c.d.z')); - assert(!app.store.hasOwn('a.b.c.e.bar')); - assert(!app.store.has('a.b.g.j.k')); - assert(!app.store.hasOwn('a.b.g.j.foo')); - }); - - it('should `.get()` a stored value', function() { - app.store.set('three', 'four'); - app.store.get('three').should.equal('four'); - }); - - it('should `.get()` a nested value', function() { - app.store.set({a: {b: {c: 'd'}}}); - app.store.get('a.b.c').should.equal('d'); - }); - - it('should `.del()` a stored value', function() { - app.store.set('a', 'b'); - app.store.set('c', 'd'); - app.store.del('a'); - assert(!app.store.hasOwnProperty('a')); - }); - - it('should `.del()` multiple stored values', function() { - app.store.set('a', 'b'); - app.store.set('c', 'd'); - app.store.set('e', 'f'); - app.store.del(['a', 'c', 'e']); - app.store.data.should.eql({}); - }); -}); - -describe('events', function() { - beforeEach(function() { - app = new App(); - app.store = new Store('update-tests'); - }); - - afterEach(function(cb) { - app.store.del({force: true}); - cb(); - }); - - it('should emit `set` when an object is set:', function() { - var keys = []; - app.store.on('set', function(key) { - keys.push(key); - }); - - app.store.set({a: {b: {c: 'd'}}}); - assert(keys[0] === 'a'); - }); - - it('should emit `set` when a key/value pair is set:', function() { - var keys = []; - app.store.on('set', function(key) { - keys.push(key); - }); - - app.store.set('a', 'b'); - assert(keys[0] === 'a'); - }); - - it('should emit `set` when an object value is set:', function() { - var keys = []; - app.store.on('set', function(key) { - keys.push(key); - }); - - app.store.set('a', {b: 'c'}); - assert(keys[0] === 'a'); - }); - - it('should emit `set` when an array of objects is passed:', function() { - var keys = []; - app.store.on('set', function(key) { - keys.push(key); - }); - - app.store.set([{a: 'b'}, {c: 'd'}]); - assert(keys[0] === 'a'); - assert(keys[1] === 'c'); - }); - - it('should emit `del` when a value is deleted:', function(cb) { - app.store.on('del', function(key) { - assert(key === 'a'); - cb(); - }); - - app.store.set('a', {b: 'c'}); - app.store.get('a').should.eql({b: 'c'}); - app.store.del('a'); - }); - - it('should emit deleted keys on `del`:', function(cb) { - app.store.once('del', function(key) { - console.log(key) - assert(key === 'a'); - cb(); - }); - - app.store.set('a', 'b'); - app.store.set('c', 'd'); - app.store.set('e', 'f'); - assert.deepEqual(Object.keys(app.store.data), ['a', 'c', 'e']); - app.store.del({force: true}); - assert.deepEqual(Object.keys(app.store.data), []); - }); -}); diff --git a/vendors/update/test/support/ignore.js b/vendors/update/test/support/ignore.js deleted file mode 100644 index 7dcbb755..00000000 --- a/vendors/update/test/support/ignore.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = [ - 'addEventListener', - 'removeEventListener', - 'removeAllListeners', - 'removeListener' -]; diff --git a/vendors/update/test/support/index.js b/vendors/update/test/support/index.js deleted file mode 100644 index e2194a5c..00000000 --- a/vendors/update/test/support/index.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var path = require('path'); -var loadpkg = require('load-pkg'); -var assert = require('assert'); -var ignore = require('./ignore'); -var cache = {}; - -exports.containEql = function containEql(actual, expected) { - if (Array.isArray(expected)) { - var len = expected.length; - while (len--) { - exports.containEql(actual[len], expected[len]); - } - } else { - for (var key in expected) { - assert.deepEqual(actual[key], expected[key]); - } - } -}; - -exports.keys = function keys(obj) { - var arr = []; - for (var key in obj) { - if (ignore.indexOf(key) === -1) { - arr.push(key); - } - } - return arr; -}; - -exports.resolve = function(filepath) { - filepath = filepath || ''; - var key = 'app:' + filepath; - if (cache.hasOwnProperty(key)) { - return cache[key]; - } - - var pkg = loadpkg.sync(process.cwd()); - var prefix = pkg.name !== 'templates' - ? 'templates' - : ''; - - var base = filepath - ? path.join(prefix, filepath) - : process.cwd(); - - var fp = tryResolve(base); - - if (typeof fp === 'undefined') { - throw new Error('cannot resolve: ' + fp); - } - return (cache[key] = require(fp)); -}; - -function tryResolve(name) { - try { - return require.resolve(name); - } catch (err) {} - - try { - return require.resolve(path.resolve(name)); - } catch (err) {} -} diff --git a/vendors/update/test/support/spy.js b/vendors/update/test/support/spy.js deleted file mode 100644 index e14512b2..00000000 --- a/vendors/update/test/support/spy.js +++ /dev/null @@ -1,27 +0,0 @@ -var fs = require('fs'); -var sinon = require('sinon'); - -var errorfn = false; - -function maybeCallAsync(module, func) { - var original = module[func]; - return sinon.stub(module, func, function() { - var args = Array.prototype.slice.call(arguments); - args.unshift(module, func); - var err = typeof errorfn === 'function' && - errorfn.apply(this, args); - if (!err) { - original.apply(this, arguments); - } else { - arguments[arguments.length - 1](err); - } - }); -} - -module.exports = { - setError: function(fn) { - errorfn = fn; - }, - chmodSpy: maybeCallAsync(fs, 'chmod'), - statSpy: maybeCallAsync(fs, 'stat') -}; diff --git a/vendors/update/test/view.content.js b/vendors/update/test/view.content.js deleted file mode 100644 index 80ea1135..00000000 --- a/vendors/update/test/view.content.js +++ /dev/null @@ -1,29 +0,0 @@ -require('mocha'); -require('should'); -var fs = require('fs'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('content', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - app.engine('tmpl', require('engine-base')); - }); - - it('should normalize the `content` property on a view to a string:', function(done) { - app.page('abc', {path: 'test/fixtures/templates/a.tmpl'}) - .set('read', function() { - this.contents = fs.readFileSync(this.path); - return this; - }); - - app.views.pages.abc.read(); - - assert('content' in app.views.pages.abc); - assert(typeof app.views.pages.abc.content === 'string'); - done(); - }); -}); diff --git a/vendors/update/test/view.events.js b/vendors/update/test/view.events.js deleted file mode 100644 index 3956379e..00000000 --- a/vendors/update/test/view.events.js +++ /dev/null @@ -1,28 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('view.option()', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - }); - - it('should emit events:', function() { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}); - var page = app.pages.getView('a.tmpl'); - var events = []; - - page.on('option', function(key) { - events.push(key); - }); - - page.option('a', 'b'); - page.option('c', 'd'); - page.option('e', 'f'); - page.option({g: 'h'}); - - events.should.eql(['a', 'c', 'e', 'g']); - }); -}); diff --git a/vendors/update/test/view.js b/vendors/update/test/view.js deleted file mode 100644 index 92ddf3c6..00000000 --- a/vendors/update/test/view.js +++ /dev/null @@ -1,1148 +0,0 @@ -require('mocha'); -var should = require('should'); -var fs = require('fs'); -var path = require('path'); -var assert = require('assert'); -var Stream = require('stream'); -var es = require('event-stream'); -var support = require('./support'); -var App = support.resolve(); -var View = App.View; -var view; - -describe('View', function() { - describe('instance', function() { - it('should create an instance of View:', function() { - view = new View(); - assert(view instanceof View); - }); - }); - - describe('static methods', function() { - it('should expose `extend`:', function() { - assert(typeof View.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - view = new View(); - }); - - it('should expose `set`:', function() { - assert(typeof view.set === 'function'); - }); - it('should expose `get`:', function() { - assert(typeof view.get === 'function'); - }); - it('should expose `del`:', function() { - assert(typeof view.del === 'function'); - }); - it('should expose `define`:', function() { - assert(typeof view.define === 'function'); - }); - it('should expose `visit`:', function() { - assert(typeof view.visit === 'function'); - }); - it('should expose `compile`:', function() { - assert(typeof view.compile === 'function'); - }); - it('should expose `render`:', function() { - assert(typeof view.render === 'function'); - }); - it('should expose `isType`:', function() { - assert(typeof view.isType === 'function'); - }); - }); - - describe('properties', function() { - it('should expose an `options` property', function() { - view = new View({}); - assert.deepEqual(view.options, {}); - assert(view.hasOwnProperty('options')); - }); - - it('should add `options` when passed on the constructor', function() { - view = new View({options: {foo: 'bar'}}); - assert(view.options.foo === 'bar'); - }); - - it('should expose a `data` property', function() { - view = new View({app: {}}); - assert.deepEqual(view.data, {}); - assert(view.hasOwnProperty('data')); - }); - - it('should add `data` when passed on the constructor', function() { - view = new View({data: {foo: 'bar'}}); - assert(view.data.foo === 'bar'); - }); - - it('should add `locals` when passed on the constructor', function() { - view = new View({locals: {foo: 'bar'}}); - assert(view.locals.foo === 'bar'); - }); - }); - - describe('set', function() { - it('should set properties on the object', function() { - view = new View(); - view.set('foo', 'bar'); - assert.equal(view.foo, 'bar'); - }); - }); - - describe('get', function() { - it('should get properties from the object', function() { - view = new View(); - view.set('foo', 'bar'); - assert.equal(view.get('foo'), 'bar'); - }); - }); - - describe('cwd', function() { - it('should get properties from the object', function() { - view = new View({cwd: 'test/fixtures'}); - assert(view.cwd === 'test/fixtures'); - }); - }); - - describe('clone', function() { - it('should clone the view:', function() { - view = new View({content: 'foo'}); - view.set({path: 'foo/bar'}); - view.set('options.one', 'two'); - var clone = view.clone(); - assert(clone.contents); - clone.set('baz', 'quux'); - clone.set('options.three', 'four'); - assert.equal(clone.get('foo'), view.get('foo')); - assert(clone.get('baz') === 'quux'); - assert(!view.get('baz')); - // not deep cloned - assert(clone.get('options.three') === 'four'); - assert(view.get('options.three') === 'four'); - }); - - it('should deep clone the entire object', function() { - view = new View({content: 'foo'}); - view.set({path: 'foo/bar'}); - view.set('options.one', 'two'); - var clone = view.clone({deep: true}); - clone.set('options.three', 'four'); - assert(view.get('options.one') === 'two'); - assert(clone.get('options.one') === 'two'); - assert(clone.get('options.three') === 'four'); - assert(!view.get('options.three')); - }); - }); - - describe('visit', function() { - it('should visit all properties on an object and call the specified method', function() { - view = new View(); - var obj = { - foo: 'bar', - bar: 'baz', - baz: 'bang' - }; - view.visit('set', obj); - assert.equal(view.get('foo'), 'bar'); - assert.equal(view.get('bar'), 'baz'); - assert.equal(view.get('baz'), 'bang'); - }); - - it('should visit all properties on all objects in an array and call the specified method', function() { - view = new View(); - var arr = [{foo: 'bar', bar: 'baz', baz: 'bang'}]; - view.visit('set', arr); - assert.equal(view.get('foo'), 'bar'); - assert.equal(view.get('bar'), 'baz'); - assert.equal(view.get('baz'), 'bang'); - }); - }); - - describe('compile', function() { - it('should get view.layout from view.data.layout', function() { - view = new View({path: 'foo', contents: 'a b c', data: {layout: 'default'}}); - assert(view.layout === 'default'); - }); - it('should get view.layout from view.options.layout', function() { - view = new View({path: 'foo', contents: 'a b c', options: {layout: 'default'}}); - assert(view.layout === 'default'); - }); - it('should get view.layout from view.locals.layout', function() { - view = new View({path: 'foo', contents: 'a b c', locals: {layout: 'default'}}); - assert(view.layout === 'default'); - }); - it('should get view.layout from the view', function() { - view = new View({path: 'foo', contents: 'a b c', layout: 'default'}); - assert(view.layout === 'default'); - }); - - it('should add a compiled function to `view.fn`', function() { - view = new View({path: 'foo', contents: 'a <%= name %> z'}); - view.compile(); - assert(typeof view.fn === 'function'); - }); - - it('should render a compiled template', function(done) { - view = new View({path: 'foo', contents: 'a <%= name %> z'}); - view.compile(); - view.render({name: 'Halle'}, function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a Halle z'); - done(); - }); - }); - - it('should render `fn` using data passed on the constructor', function(done) { - view = new View({ - path: 'foo', - contents: 'a <%= name %> z', - data: { - name: 'Brooke' - } - }); - - view.compile(); - view.render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a Brooke z'); - done(); - }); - }); - }); - - describe('render', function() { - it('should render a template', function(done) { - view = new View({path: 'foo', contents: 'a <%= name %> z'}); - view.render({name: 'Halle'}, function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a Halle z'); - done(); - }); - }); - - it('should render fn using data passed on the constructor', function(done) { - view = new View({ - path: 'foo', - contents: 'a <%= name %> z', - data: { - name: 'Brooke' - } - }); - - view.render(function(err, res) { - if (err) return done(err); - assert(res.contents.toString() === 'a Brooke z'); - done(); - }); - }); - - it('should pass errors in the callback.', function(done) { - view = new View({ - path: 'foo', - contents: 'a <%= name %> z' - }); - - view.render(function(err) { - assert(err.message === 'name is not defined'); - done(); - }); - }); - }); -}); - -/** - * The following unit tests are from Vinyl - * Since we inherit vinyl in View, we need - * to ensure that these still pass. - */ - -describe('View', function() { - describe('isVinyl()', function() { - it('should return true on a vinyl object', function(done) { - var view = new View(); - assert(View.isVinyl(view) === true); - done(); - }); - it('should return false on a normal object', function(done) { - assert(View.isVinyl({}) === false); - done(); - }); - it('should return false on a null object', function(done) { - assert(View.isVinyl({}) === false); - done(); - }); - }); - - describe('constructor()', function() { - it('should default cwd to process.cwd', function(done) { - var view = new View(); - view.cwd.should.equal(process.cwd()); - done(); - }); - - it('should default base to cwd', function(done) { - var cwd = '/'; - var view = new View({cwd: cwd}); - view.base.should.equal(cwd); - done(); - }); - - it('should default base to cwd even when none is given', function(done) { - var view = new View(); - view.base.should.equal(process.cwd()); - done(); - }); - - it('should default path to null', function(done) { - var view = new View(); - should.not.exist(view.path); - done(); - }); - - it('should default history to []', function(done) { - var view = new View(); - view.history.should.eql([]); - done(); - }); - - it('should default stat to null', function(done) { - var view = new View(); - should.not.exist(view.stat); - done(); - }); - - it('should default contents to null', function(done) { - var view = new View(); - should.not.exist(view.contents); - done(); - }); - - it('should set base to given value', function(done) { - var val = '/'; - var view = new View({base: val}); - view.base.should.equal(val); - done(); - }); - - it('should set cwd to given value', function(done) { - var val = '/'; - var view = new View({cwd: val}); - view.cwd.should.equal(val); - done(); - }); - - it('should set path to given value', function(done) { - var val = '/test.coffee'; - var view = new View({path: val}); - view.path.should.equal(val); - view.history.should.eql([val]); - done(); - }); - - it('should set history to given value', function(done) { - var val = '/test.coffee'; - var view = new View({history: [val]}); - view.path.should.equal(val); - view.history.should.eql([val]); - done(); - }); - - it('should set stat to given value', function(done) { - var val = {}; - var view = new View({stat: val}); - view.stat.should.equal(val); - done(); - }); - - it('should set contents to given value', function(done) { - var val = new Buffer('test'); - var view = new View({contents: val}); - view.contents.should.equal(val); - done(); - }); - }); - - describe('isBuffer()', function() { - it('should return true when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var view = new View({contents: val}); - view.isBuffer().should.equal(true); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var view = new View({contents: val}); - assert(!view.isBuffer()); - done(); - }); - - it('should return false when the contents are a null', function(done) { - var view = new View({contents: null}); - assert(!view.isBuffer()); - done(); - }); - }); - - describe('isStream()', function() { - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var view = new View({contents: val}); - assert(!view.isStream()); - done(); - }); - - it('should return true when the contents are a Stream', function(done) { - var val = new Stream(); - var view = new View({contents: val}); - view.isStream().should.equal(true); - done(); - }); - - it('should return false when the contents are a null', function(done) { - var view = new View({contents: null}); - assert(!view.isStream()); - done(); - }); - }); - - describe('isNull()', function() { - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var view = new View({contents: val}); - assert(!view.isNull()); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var view = new View({contents: val}); - assert(!view.isNull()); - done(); - }); - - it('should return true when the contents are a null', function(done) { - var view = new View({contents: null}); - view.isNull().should.equal(true); - done(); - }); - }); - - describe('isDirectory()', function() { - var fakeStat = { - isDirectory: function() { - return true; - } - }; - - it('should return false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var view = new View({contents: val, stat: fakeStat}); - assert(!view.isDirectory()); - done(); - }); - - it('should return false when the contents are a Stream', function(done) { - var val = new Stream(); - var view = new View({contents: val, stat: fakeStat}); - assert(!view.isDirectory()); - done(); - }); - - it('should return true when the contents are a null', function(done) { - var view = new View({contents: null, stat: fakeStat}); - view.isDirectory().should.equal(true); - done(); - }); - }); - - describe('clone()', function() { - it('should copy all attributes over with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var view = new View(options); - var view2 = view.clone(); - - view2.should.not.equal(view, 'refs should be different'); - view2.cwd.should.equal(view.cwd); - view2.base.should.equal(view.base); - view2.path.should.equal(view.path); - view2.contents.should.not.equal(view.contents, 'buffer ref should be different'); - view2.contents.toString('utf8').should.equal(view.contents.toString('utf8')); - done(); - }); - - it('should copy buffer\'s reference with option contents: false', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test') - }; - - var view = new View(options); - - var copy1 = view.clone({ contents: false }); - copy1.contents.should.equal(view.contents); - - var copy2 = view.clone({}); - copy2.contents.should.not.equal(view.contents); - - var copy3 = view.clone({ contents: 'any string' }); - copy3.contents.should.not.equal(view.contents); - - done(); - }); - - it('should copy all attributes over with Stream', function(done) { - var contents = new Stream.PassThrough(); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: contents - }; - var view = new View(options); - var view2 = view.clone(); - - contents.write(new Buffer('wa')); - - process.nextTick(function() { - contents.write(new Buffer('dup')); - contents.end(); - }); - - view2.should.not.equal(view, 'refs should be different'); - view2.cwd.should.equal(view.cwd); - view2.base.should.equal(view.base); - view2.path.should.equal(view.path); - view2.contents.should.not.equal(view.contents, 'stream ref should not be the same'); - view.contents.pipe(es.wait(function(err, data) { - if (err) return done(err); - view2.contents.pipe(es.wait(function(err, data2) { - if (err) return done(err); - data2.should.not.equal(data, 'stream contents ref should not be the same'); - data2.should.eql(data, 'stream contents should be the same'); - })); - })); - done(); - }); - - it('should copy all attributes over with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var view = new View(options); - var view2 = view.clone(); - - view2.should.not.equal(view, 'refs should be different'); - view2.cwd.should.equal(view.cwd); - view2.base.should.equal(view.base); - view2.path.should.equal(view.path); - should.not.exist(view2.contents); - done(); - }); - - it('should properly clone the `stat` property', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test'), - stat: fs.statSync(__filename) - }; - - var view = new View(options); - var copy = view.clone(); - - assert(copy.stat.isFile()); - assert(!copy.stat.isDirectory()); - done(); - }); - - it('should properly clone the `history` property', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.js', - contents: new Buffer('test'), - stat: fs.statSync(__filename) - }; - - var view = new View(options); - var copy = view.clone(); - - copy.history[0].should.equal(options.path); - copy.path = 'lol'; - view.path.should.not.equal(copy.path); - done(); - }); - - it('should copy custom properties', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var view = new View(options); - view.custom = { a: 'custom property' }; - var view2 = view.clone(); - - view2.should.not.equal(view, 'refs should be different'); - view2.cwd.should.equal(view.cwd); - view2.base.should.equal(view.base); - view2.path.should.equal(view.path); - view2.custom.should.equal(view.custom); - view2.custom.a.should.equal(view.custom.a); - - done(); - }); - - it('should copy history', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var view = new View(options); - view.path = '/test/test.js'; - view.path = '/test/test-938di2s.js'; - var view2 = view.clone(); - - view2.history.should.eql([ - '/test/test.coffee', - '/test/test.js', - '/test/test-938di2s.js' - ]); - view2.history.should.not.equal([ - '/test/test.coffee', - '/test/test.js', - '/test/test-938di2s.js' - ]); - view2.path.should.eql('/test/test-938di2s.js'); - - done(); - }); - - it('should copy all attributes deeply', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - - var view = new View(options); - view.custom = { a: 'custom property' }; - - var view2 = view.clone(true); - view2.custom.should.eql(view.custom); - view2.custom.should.not.equal(view.custom); - view2.custom.a.should.equal(view.custom.a); - - var view3 = view.clone({ deep: true }); - view3.custom.should.eql(view.custom); - view3.custom.should.not.equal(view.custom); - view3.custom.a.should.equal(view.custom.a); - - var view4 = view.clone(false); - view4.custom.should.eql(view.custom); - view4.custom.should.equal(view.custom); - view4.custom.a.should.equal(view.custom.a); - - var view5 = view.clone({ deep: false }); - view5.custom.should.eql(view.custom); - view5.custom.should.equal(view.custom); - view5.custom.a.should.equal(view.custom.a); - - done(); - }); - }); - - describe('pipe()', function() { - it('should write to stream with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(options.contents.toString('utf8')); - }); - stream.on('end', function() { - done(); - }); - var ret = view.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should pipe to stream with Stream', function(done) { - var testChunk = new Buffer('test'); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(testChunk.toString('utf8')); - done(); - }); - var ret = view.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - - view.contents.write(testChunk); - }); - - it('should do nothing with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function() { - throw new Error('should not write'); - }); - stream.on('end', function() { - done(); - }); - var ret = view.pipe(stream); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should write to stream with Buffer', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Buffer('test') - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(options.contents.toString('utf8')); - done(); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = view.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - }); - - it('should pipe to stream with Stream', function(done) { - var testChunk = new Buffer('test'); - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function(chunk) { - should.exist(chunk); - (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); - chunk.toString('utf8').should.equal(testChunk.toString('utf8')); - done(); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = view.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - - view.contents.write(testChunk); - }); - - it('should do nothing with null', function(done) { - var options = { - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }; - var view = new View(options); - var stream = new Stream.PassThrough(); - stream.on('data', function() { - throw new Error('should not write'); - }); - stream.on('end', function() { - throw new Error('should not end'); - }); - var ret = view.pipe(stream, {end: false}); - ret.should.equal(stream, 'should return the stream'); - process.nextTick(done); - }); - }); - - describe('inspect()', function() { - it('should return correct format when no contents and no path', function(done) { - var view = new View(); - view.inspect().should.equal(''); - done(); - }); - - it('should return correct format when Buffer and no path', function(done) { - var val = new Buffer('test'); - var view = new View({ - contents: val - }); - view.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Buffer and relative path', function(done) { - var val = new Buffer('test'); - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: val - }); - view.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Buffer and only path and no base', function(done) { - var val = new Buffer('test'); - var view = new View({ - cwd: '/', - path: '/test/test.coffee', - contents: val - }); - delete view.base; - view.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when Stream and relative path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: new Stream.PassThrough() - }); - view.inspect().should.equal('>'); - done(); - }); - - it('should return correct format when null and relative path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee', - contents: null - }); - view.inspect().should.equal(''); - done(); - }); - }); - - describe('contents get/set', function() { - it('should work with Buffer', function(done) { - var val = new Buffer('test'); - var view = new View(); - view.contents = val; - view.contents.should.equal(val); - done(); - }); - - it('should work with Stream', function(done) { - var val = new Stream.PassThrough(); - var view = new View(); - view.contents = val; - view.contents.should.equal(val); - done(); - }); - - it('should work with null', function(done) { - var val = null; - var view = new View(); - view.contents = val; - (view.contents === null).should.equal(true); - done(); - }); - - it('should work with string', function(done) { - var val = 'test'; - var view = new View(); - view.contents = val; - view.contents.should.deepEqual(new Buffer(val)); - done(); - }); - }); - - describe('relative get/set', function() { - it('should error on set', function(done) { - var view = new View(); - try { - view.relative = 'test'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should error on get when no base', function(done) { - var view = new View(); - delete view.base; - try { - view.relative; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should error on get when no path', function(done) { - var view = new View(); - try { - view.relative; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return a relative path from base', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.relative.should.equal('test.coffee'); - done(); - }); - - it('should return a relative path from cwd', function(done) { - var view = new View({ - cwd: '/', - path: '/test/test.coffee' - }); - view.relative.should.equal(path.join('test', 'test.coffee')); - done(); - }); - }); - - describe('dirname get/set', function() { - it('should error on get when no path', function(done) { - var view = new View(); - try { - view.dirname; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the dirname of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.dirname.should.equal('/test'); - done(); - }); - - it('should error on set when no path', function(done) { - var view = new View(); - try { - view.dirname = '/test'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the dirname of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.dirname = '/test/foo'; - view.path.should.equal('/test/foo/test.coffee'); - done(); - }); - }); - - describe('basename get/set', function() { - it('should error on get when no path', function(done) { - var view = new View(); - try { - view.basename; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the basename of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.basename.should.equal('test.coffee'); - done(); - }); - - it('should error on set when no path', function(done) { - var view = new View(); - try { - view.basename = 'test.coffee'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the basename of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.basename = 'foo.png'; - view.path.should.equal('/test/foo.png'); - done(); - }); - }); - - describe('extname get/set', function() { - it('should error on get when no path', function(done) { - var view = new View(); - try { - view.extname; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should return the extname of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.extname.should.equal('.coffee'); - done(); - }); - - it('should error on set when no path', function(done) { - var view = new View(); - try { - view.extname = '.coffee'; - } catch (err) { - should.exist(err); - done(); - } - }); - - it('should set the extname of the path', function(done) { - var view = new View({ - cwd: '/', - base: '/test/', - path: '/test/test.coffee' - }); - view.extname = '.png'; - view.path.should.equal('/test/test.png'); - done(); - }); - }); - - describe('path get/set', function() { - it('should record history when instantiation', function() { - var view = new View({ - cwd: '/', - path: '/test/test.coffee' - }); - - view.path.should.eql('/test/test.coffee'); - view.history.should.eql(['/test/test.coffee']); - }); - - it('should record history when path change', function() { - var view = new View({ - cwd: '/', - path: '/test/test.coffee' - }); - - view.path = '/test/test.js'; - view.path.should.eql('/test/test.js'); - view.history.should.eql(['/test/test.coffee', '/test/test.js']); - - view.path = '/test/test.coffee'; - view.path.should.eql('/test/test.coffee'); - view.history.should.eql(['/test/test.coffee', '/test/test.js', '/test/test.coffee']); - }); - - it('should not record history when set the same path', function() { - var view = new View({ - cwd: '/', - path: '/test/test.coffee' - }); - - view.path = '/test/test.coffee'; - view.path = '/test/test.coffee'; - view.path.should.eql('/test/test.coffee'); - view.history.should.eql(['/test/test.coffee']); - - // ignore when set empty string - view.path = ''; - view.path.should.eql('/test/test.coffee'); - view.history.should.eql(['/test/test.coffee']); - }); - - it('should throw when set path null in constructor', function() { - (function() { - View({ - cwd: '/', - path: null - }); - }).should.throw('path should be string'); - }); - - it('should throw when set path null', function() { - var view = new View({ - cwd: '/', - path: 'foo' - }); - - (function() { - view.path = null; - }).should.throw('path should be string'); - }); - }); -}); diff --git a/vendors/update/test/view.methods.js b/vendors/update/test/view.methods.js deleted file mode 100644 index 08f064e5..00000000 --- a/vendors/update/test/view.methods.js +++ /dev/null @@ -1,39 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('view.option()', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('page'); - }); - - describe('.use', function() { - it('should expose `.use` for running plugins on a view:', function() { - app.page('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}) - .use(function() { - this.options.foo = 'bar'; - }) - .use(function() { - this.options.bar = 'baz'; - }); - - var page = app.pages.getView('a.tmpl'); - page.options.should.have.property('foo'); - page.options.should.have.property('bar'); - }); - }); - - describe('.render:', function() { - it('should expose `.render` for rendering a view:', function(done) { - app.page('a.tmpl', {path: 'a.tmpl', content: '<%= a %>', locals: {a: 'bbb'}}) - .render({}, function(err, res) { - if (err) return done(err); - res.contents.toString().should.equal('bbb'); - done(); - }); - }); - }); -}); diff --git a/vendors/update/test/view.option.js b/vendors/update/test/view.option.js deleted file mode 100644 index 087399c1..00000000 --- a/vendors/update/test/view.option.js +++ /dev/null @@ -1,29 +0,0 @@ -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('view.option()', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - }); - - it('should set an option:', function() { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}); - var page = app.pages.getView('a.tmpl'); - - page.options.should.not.have.property('foo'); - page.option('foo', 'bar'); - page.options.should.have.property('foo'); - }); - - it('should extend options:', function() { - app.pages('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}); - var page = app.pages.getView('a.tmpl'); - page.option('a', 'b'); - page.option('c', 'd'); - page.option('e', 'f'); - page.options.should.have.properties(['a', 'c', 'e']); - }); -}); diff --git a/vendors/update/test/view.render.js b/vendors/update/test/view.render.js deleted file mode 100644 index a7d6d71f..00000000 --- a/vendors/update/test/view.render.js +++ /dev/null @@ -1,52 +0,0 @@ -require('mocha'); -require('should'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('helpers', function() { - describe('rendering', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - app.create('layouts', {viewType: 'layout'}); - app.create('pages'); - }); - - it('should expose `.render` for rendering a view:', function(done) { - app.page('a.tmpl', {path: 'a.tmpl', content: '<%= a %>'}) - .render({a: 'bbb'}, function(err, res) { - if (err) return done(err); - res.content.should.equal('bbb'); - done(); - }); - }); - - it('should render a view with a layout', function(done) { - app.layout('default.tmpl', {content: 'a {% body %} b'}); - app.page('a.tmpl', {content: '<%= title %>', layout: 'default.tmpl'}) - .render({title: 'zzz'}, function(err, res) { - if (err) return done(err); - res.content.should.equal('a zzz b'); - done(); - }); - }); - - it('should render a view with a layout', function(done) { - app.layout('foo.tmpl', {content: 'a {% body %} a'}); - app.layout('bar.tmpl', {content: 'b {% body %} b'}); - app.pages('a.tmpl', {content: '<%= title %>'}); - - app.pages.getView('a.tmpl') - .option('resolveLayout', function() { - return 'bar.tmpl'; - }) - .render({title: 'zzz'}, function(err, res) { - if (err) return done(err); - res.content.should.equal('b zzz b'); - done(); - }); - }); - }); -}); - diff --git a/vendors/update/test/view.set.js b/vendors/update/test/view.set.js deleted file mode 100644 index 018df6eb..00000000 --- a/vendors/update/test/view.set.js +++ /dev/null @@ -1,34 +0,0 @@ -require('mocha'); -require('should'); -var fs = require('fs'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('set', function() { - beforeEach(function() { - app = new App(); - app.create('page'); - app.engine('tmpl', require('engine-base')); - }); - - it('should set a property on a view:', function(done) { - app.page('abc', {path: 'test/fixtures/templates/a.tmpl'}) - .set('read', function() { - this.contents = fs.readFileSync(this.path); - return this; - }); - - assert('read' in app.views.pages.abc); - app.views.pages.abc - .read() - .set('data.name', 'Brooke') - .render(function(err, res) { - if (err) return done(err); - - assert(res.content === 'Brooke'); - done(); - }); - }); -}); diff --git a/vendors/update/test/view.use.js b/vendors/update/test/view.use.js deleted file mode 100644 index 28834245..00000000 --- a/vendors/update/test/view.use.js +++ /dev/null @@ -1,60 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var View = App.View; -var view; - -describe('view.use', function() { - beforeEach(function() { - view = new View(); - }); - - it('should expose the instance to `use`:', function(done) { - view.use(function(inst) { - assert(inst instanceof View); - done(); - }); - }); - - it('should be chainable:', function(done) { - view.use(function(inst) { - assert(inst instanceof View); - }) - .use(function(inst) { - assert(inst instanceof View); - }) - .use(function(inst) { - assert(inst instanceof View); - done(); - }); - }); - - it('should expose the view to a plugin:', function() { - view.use(function(view) { - assert(view instanceof View); - view.foo = function(str) { - return str + ' ' + 'bar'; - }; - }); - assert(view.foo('foo') === 'foo bar'); - }); - - it('should be chainable:', function() { - view - .use(function(view) { - view.a = 'aaa'; - }) - .use(function(view) { - view.b = 'bbb'; - }) - .use(function(view) { - view.c = 'ccc'; - }); - - assert(view.a === 'aaa'); - assert(view.b === 'bbb'); - assert(view.c === 'ccc'); - }); -}); diff --git a/vendors/update/test/viewTypes.js b/vendors/update/test/viewTypes.js deleted file mode 100644 index b96115e8..00000000 --- a/vendors/update/test/viewTypes.js +++ /dev/null @@ -1,52 +0,0 @@ -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var app; - -describe('viewType', function() { - describe('view types', function() { - beforeEach(function() { - app = new App(); - app.engine('tmpl', require('engine-base')); - }); - - it('should add collection (plural) to the `viewTypes` object', function() { - app.viewTypes = []; // reset - app.create('foo', {viewType: 'layout'}); - app.create('bar', {viewType: 'layout'}); - assert.deepEqual(app.viewTypes.layout, [ 'foos', 'bars' ]); - - app.create('baz', {viewType: 'renderable'}); - assert.deepEqual(app.viewTypes.renderable, [ 'bazs' ]); - }); - - it('should add collection to the given viewType', function() { - app.create('layout', {viewType: 'layout'}); - assert(app.layouts.options.viewType[0] === 'layout'); - }); - - it('should return true if a collection has the given viewType', function() { - app.create('layout', {viewType: 'layout'}); - assert(app.layouts.isType('layout')); - assert(!app.layouts.isType('partial')); - }); - - it('should add types to the collection', function() { - app.create('layout', {viewType: 'layout'}); - app.layouts.viewType('partial'); - assert(app.layouts.options.viewType[0] === 'layout'); - assert(app.layouts.options.viewType[1] === 'partial'); - }); - - it('should add a collection to multiple viewTypes', function() { - app.create('foo', {viewType: ['layout', 'renderable']}); - assert.deepEqual(app.foos.options.viewType, ['layout', 'renderable']); - }); - - it('should expose viewType on `view`', function() { - app.create('foo', {viewType: ['layout', 'renderable']}); - var a = app.foo('a', {content: ''}); - assert.deepEqual(app.foos.options.viewType, a.options.viewType); - }); - }); -}); diff --git a/vendors/update/test/views.js b/vendors/update/test/views.js deleted file mode 100644 index f3f9c21c..00000000 --- a/vendors/update/test/views.js +++ /dev/null @@ -1,525 +0,0 @@ -require('mocha'); -require('should'); -var path = require('path'); -var assert = require('assert'); -var typeOf = require('kind-of'); -var support = require('./support'); -var isBuffer = require('is-buffer'); -var App = support.resolve(); -var List = App.List; -var View = App.View; -var Views = App.Views; -var collection; - -describe('views', function() { - describe('constructor', function() { - it('should create an instance of Views:', function() { - var collection = new Views(); - assert(collection instanceof Views); - }); - - it('should instantiate without `new`:', function() { - var collection = Views(); - assert(collection instanceof Views); - }); - }); - - describe('static methods', function() { - it('should expose `extend`:', function() { - assert(typeof Views.extend === 'function'); - }); - }); - - describe('prototype methods', function() { - beforeEach(function() { - collection = new Views(); - }); - - var methods = [ - 'use', - 'setView', - 'addView', - 'addViews', - 'addList', - 'getView', - 'constructor', - 'set', - 'get', - 'del', - 'define', - 'visit', - 'on', - 'once', - 'off', - 'emit', - 'listeners', - 'hasListeners' - ]; - - methods.forEach(function(method) { - it('should expose ' + method + ' method', function() { - assert(typeof collection[method] === 'function'); - }); - }); - - it('should expose isCollection property', function() { - assert(typeof collection.isCollection === 'boolean'); - }); - - it('should expose queue property', function() { - assert(Array.isArray(collection.queue)); - }); - - it('should expose views property', function() { - assert(typeOf(collection.views) === 'object'); - }); - - it('should expose options property', function() { - assert(typeOf(collection.options) === 'object'); - }); - }); - - describe('instance', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should set a value on the instance:', function() { - collection.set('a', 'b'); - assert(collection.a === 'b'); - }); - - it('should get a value from the instance:', function() { - collection.set('a', 'b'); - assert(collection.get('a') === 'b'); - }); - }); - - describe('option', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should set a key/value pair on options:', function() { - collection.option('a', 'b'); - assert(collection.options.a === 'b'); - }); - - it('should set an object on options:', function() { - collection.option({c: 'd'}); - assert(collection.options.c === 'd'); - }); - - it('should get an option:', function() { - collection.option({c: 'd'}); - var c = collection.option('c'); - assert(c === 'd'); - }); - }); - - describe('addView', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should throw an error when args are invalid:', function() { - (function() { - collection.addView(function() {}); - }).should.throw('expected value to be an object.'); - }); - - it('should add a view to `views`:', function() { - collection.addView('foo'); - collection.views.should.have.property('foo'); - - collection.addView('one', {content: '...'}); - assert(typeof collection.views.one === 'object'); - assert(isBuffer(collection.views.one.contents)); - }); - - it('should create an instance of `View`:', function() { - collection.addView('one', {content: '...'}); - assert(collection.views.one instanceof collection.View); - }); - - it('should allow an `View` constructor to be passed:', function() { - View.prototype.foo = function(key, value) { - this[key] = value; - }; - collection = new Views({View: View}); - collection.addView('one', {content: '...'}); - collection.views.one.foo('bar', 'baz'); - assert(collection.views.one.bar === 'baz'); - }); - - it('should allow an instance of `View` to be passed:', function() { - var collection = new Views({View: View}); - var view = new View({content: '...'}); - collection.addView('one', view); - view.set('abc', 'xyz'); - assert(collection.views.one instanceof collection.View); - assert(isBuffer(collection.views.one.contents)); - assert(collection.views.one.abc === 'xyz'); - }); - - it('should expose the `isType` method on items', function() { - var collection = new Views({View: View}); - var view = new View({content: '...'}); - collection.setView('one', view); - - var one = collection.getView('one'); - assert(one.isType('renderable')); - }); - - it('should set viewTypes on a collection', function() { - var collection = new Views({View: View}); - collection.viewType(['partial']); - - var view = new View({content: '...'}); - collection.setView('one', view); - - var one = collection.getView('one'); - assert(!one.isType('renderable')); - assert(one.isType('partial')); - }); - }); - - describe('addViews', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should emit an error if a string glob pattern is passed', function(done) { - try { - collection.addViews('*.js'); - done(new Error('expected an error')); - } catch (err) { - assert(err); - assert(err.message); - assert(/glob/.test(err.message)); - done(); - } - }); - - it('should emit an error if an array glob pattern is passed', function(done) { - try { - collection.addViews(['*.js']); - done(new Error('expected an error')); - } catch (err) { - assert(err); - assert(err.message); - assert(/glob/.test(err.message)); - done(); - } - }); - - it('should add multiple views:', function() { - collection.addViews({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.views.two.contents)); - }); - - it('should return the collection instance for chaining:', function() { - var views = collection.addViews({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - - var view = views.getView('one'); - assert(view); - assert(view.content); - assert(view.content === 'foo'); - }); - - it('should create views from an instance of Views', function() { - collection.addViews({ - one: {content: 'foo'}, - two: {content: 'bar'} - }); - var pages = new Views(collection); - assert(isBuffer(pages.views.one.contents)); - assert(isBuffer(pages.views.two.contents)); - }); - - it('should add an array of views:', function() { - collection.addViews([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.views.two.contents)); - }); - }); - - describe('view', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should return a single collection view from a key-value pair', function() { - var one = collection.view('one', {content: 'foo'}); - var two = collection.view('two', {content: 'bar'}); - - assert(one.isView); - assert(one.path === 'one'); - assert(two.isView); - assert(two.path === 'two'); - }); - - it('should return a single collection view from an object', function() { - var one = collection.view({path: 'one', content: 'foo'}); - var two = collection.view({path: 'two', content: 'bar'}); - - assert(one.isView); - assert(one.path === 'one'); - assert(two.isView); - assert(two.path === 'two'); - }); - }); - - describe('addList', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should emit an error if a string glob pattern is passed', function(done) { - try { - collection.addList('*.js'); - done(new Error('expected an error')); - } catch (err) { - assert(err); - assert(err.message); - assert(/glob/.test(err.message)); - done(); - } - }); - - it('should emit an error if an array glob pattern is passed', function(done) { - try { - collection.addList(['*.js']); - done(new Error('expected an error')); - } catch (err) { - assert(err); - assert(err.message); - assert(/glob/.test(err.message)); - done(); - } - }); - - it('should add a list of views:', function() { - collection.addList([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.views.two.contents)); - }); - - it('should add a list from the constructor:', function() { - var list = new List([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - - collection = new Views(list); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.views.two.contents)); - }); - - it('should add list items from the constructor:', function() { - var list = new List([ - {path: 'one', content: 'foo'}, - {path: 'two', content: 'bar'} - ]); - - collection = new Views(list.items); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.views.two.contents)); - }); - - it('should throw an error when list is not an array:', function() { - var views = new Views(); - (function() { - views.addList(); - }).should.throw('expected list to be an array.'); - - (function() { - views.addList({}); - }).should.throw('expected list to be an array.'); - - (function() { - views.addList('foo'); - }).should.throw('expected list to be an array.'); - }); - - it('should load an array of items from an event:', function() { - var pages = new Views(); - - pages.on('addList', function(list) { - while (list.length) { - pages.addView({path: list.pop()}); - } - this.loaded = true; - }); - - pages.addList(['a.txt', 'b.txt', 'c.txt']); - assert(pages.views.hasOwnProperty('a.txt')); - assert(pages.views['a.txt'].path === 'a.txt'); - }); - - it('should load an array of items from the addList callback:', function() { - var collection = new Views(); - - collection.addList(['a.txt', 'b.txt', 'c.txt'], function(fp) { - return {path: fp}; - }); - assert(collection.views.hasOwnProperty('a.txt')); - assert(collection.views['a.txt'].path === 'a.txt'); - }); - - it('should load an object of views from an event:', function() { - var collection = new Views(); - - collection.on('addViews', function(views) { - for (var key in views) { - collection.addView('foo/' + key, views[key]); - delete views[key]; - } - }); - - collection.addViews({ - a: {path: 'a.txt'}, - b: {path: 'b.txt'}, - c: {path: 'c.txt'} - }); - - assert(collection.views.hasOwnProperty('foo/a')); - assert(collection.views['foo/a'].path === 'a.txt'); - }); - - it('should signal `loaded` when finished:', function() { - var collection = new Views(); - - collection.on('addViews', function(views) { - for (var key in views) { - if (key === 'c') break; - collection.addView('foo/' + key, views[key]); - } - }); - - collection.addViews({ - a: {path: 'a.txt'}, - b: {path: 'b.txt'}, - c: {path: 'c.txt'} - }); - - assert(collection.views.hasOwnProperty('foo/a')); - assert(!collection.views.hasOwnProperty('foo/c')); - assert(collection.views['foo/a'].path === 'a.txt'); - }); - }); - - describe('getView', function() { - beforeEach(function() { - collection = new Views(); - }); - it('should get a view from `views`:', function() { - collection.addView('one', {content: 'aaa'}); - collection.addView('two', {content: 'zzz'}); - assert(isBuffer(collection.views.one.contents)); - assert(isBuffer(collection.getView('one').contents)); - assert(collection.getView('one').contents.toString() === 'aaa'); - assert(collection.getView('two').contents.toString() === 'zzz'); - }); - }); - - describe('count', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should get the number of views:', function() { - collection.addView('one', {content: 'aaa'}); - collection.addView('two', {content: 'zzz'}); - assert(Object.keys(collection.views).length === 2); - }); - }); -}); - -describe('options', function() { - describe('options.renameKey', function() { - beforeEach(function() { - collection = new Views({ - renameKey: function(key) { - return path.basename(key); - } - }); - }); - - it('should use a custom rename key function on view keys', function() { - collection.addView('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.views['d.hbs'].contents.toString() === 'foo bar baz'); - }); - - it('should get a view with the renamed key:', function() { - collection.addView('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.getView('d.hbs').contents.toString() === 'foo bar baz'); - }); - - it('should get a view with the original key:', function() { - collection.addView('a/b/c/d.hbs', {content: 'foo bar baz'}); - assert(collection.getView('a/b/c/d.hbs').contents.toString() === 'foo bar baz'); - }); - }); -}); - -describe('queue', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should emit arguments on addView', function(done) { - collection.on('addView', function(args) { - assert(args[0] === 'a'); - assert(args[1] === 'b'); - assert(args[2] === 'c'); - assert(args[3] === 'd'); - assert(args[4] === 'e'); - done(); - }); - - collection.addView('a', 'b', 'c', 'd', 'e'); - }); - - it('should expose the `queue` property for loading views', function() { - collection.queue.push(collection.view('b', {path: 'b'})); - - collection.addView('a', {path: 'a'}); - assert(collection.views.hasOwnProperty('a')); - assert(collection.views.hasOwnProperty('b')); - }); - - it('should load all views on the queue when addView is called', function() { - collection.on('addView', function(args) { - var len = args.length; - var last = args[len - 1]; - if (typeof last === 'string') { - args[len - 1] = { content: last }; - } - }); - - collection.addView('a.html', 'aaa'); - collection.addView('b.html', 'bbb'); - collection.addView('c.html', 'ccc'); - - assert(collection.views.hasOwnProperty('a.html')); - assert(collection.getView('a.html').content === 'aaa'); - assert(collection.views.hasOwnProperty('b.html')); - assert(collection.getView('b.html').content === 'bbb'); - assert(collection.views.hasOwnProperty('c.html')); - assert(collection.getView('c.html').content === 'ccc'); - }); -}); diff --git a/vendors/update/test/views.use.js b/vendors/update/test/views.use.js deleted file mode 100644 index 4329b316..00000000 --- a/vendors/update/test/views.use.js +++ /dev/null @@ -1,156 +0,0 @@ -require('mocha'); -require('should'); -var assert = require('assert'); -var support = require('./support'); -var App = support.resolve(); -var Views = App.Views; -var View = App.View; -var collection; - -describe('views.use', function() { - beforeEach(function() { - collection = new Views(); - }); - - it('should expose the instance to `use`:', function(done) { - collection.use(function(inst) { - assert(inst instanceof Views); - done(); - }); - }); - - it('should be chainable:', function(done) { - collection.use(function(inst) { - assert(inst instanceof Views); - }) - .use(function(inst) { - assert(inst instanceof Views); - }) - .use(function(inst) { - assert(inst instanceof Views); - done(); - }); - }); - - it('should expose the collection to a plugin:', function() { - collection.use(function(views) { - assert(views instanceof Views); - views.foo = views.addView.bind(views); - }); - - collection.foo('a', {content: '...'}); - assert(collection.views.hasOwnProperty('a')); - }); - - it('should expose collection when chained:', function() { - collection - .use(function(views) { - assert(views instanceof Views); - views.foo = views.addView.bind(views); - }) - .use(function(views) { - assert(views instanceof Views); - views.bar = views.addView.bind(views); - }) - .use(function(views) { - assert(views instanceof Views); - views.baz = views.addView.bind(views); - }); - - var pages = collection; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(collection.views.hasOwnProperty('a')); - assert(collection.views.hasOwnProperty('b')); - assert(collection.views.hasOwnProperty('c')); - }); - - it('should work when a custom `View` constructor is passed:', function() { - collection = new Views({View: require('vinyl')}); - collection - .use(function(views) { - assert(views instanceof Views); - views.foo = views.addView.bind(views); - }) - .use(function(views) { - assert(views instanceof Views); - views.bar = views.addView.bind(views); - }) - .use(function(views) { - assert(views instanceof Views); - views.baz = views.addView.bind(views); - }); - - var pages = collection; - - pages.foo({path: 'a', content: '...'}); - pages.bar({path: 'b', content: '...'}); - pages.baz({path: 'c', content: '...'}); - - assert(collection.views.hasOwnProperty('a')); - assert(collection.views.hasOwnProperty('b')); - assert(collection.views.hasOwnProperty('c')); - }); - - it('should pass to view `use` if a function is returned:', function() { - collection.use(function(views) { - assert(views instanceof Views); - - return function(view) { - view.foo = views.addView.bind(views); - assert(view instanceof View); - }; - }); - - collection.addView('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .foo({path: 'c', content: '...'}) - .foo({path: 'd', content: '...'}); - - assert(collection.views.hasOwnProperty('a')); - assert(collection.views.hasOwnProperty('b')); - assert(collection.views.hasOwnProperty('c')); - assert(collection.views.hasOwnProperty('d')); - }); - - it('should be chainable when a view function is returned:', function() { - collection - .use(function(views) { - assert(views instanceof Views); - - return function(view) { - view.foo = views.addView.bind(views); - assert(view instanceof View); - }; - }) - .use(function(views) { - assert(views instanceof Views); - - return function(view) { - view.bar = views.addView.bind(views); - assert(view instanceof View); - }; - }) - .use(function(views) { - assert(views instanceof Views); - - return function(view) { - view.baz = views.addView.bind(views); - assert(view instanceof View); - }; - }); - - collection.addView('a', {content: '...'}) - .foo({path: 'b', content: '...'}) - .bar({path: 'c', content: '...'}) - .baz({path: 'd', content: '...'}); - - assert(collection.views.hasOwnProperty('a')); - assert(collection.views.hasOwnProperty('b')); - assert(collection.views.hasOwnProperty('c')); - assert(collection.views.hasOwnProperty('d')); - }); -}); diff --git a/vendors/update/updatefile.js b/vendors/update/updatefile.js deleted file mode 100644 index 21264036..00000000 --- a/vendors/update/updatefile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -/** - * temporary noop - */ - -module.exports = function() {};