docpad / docpad-plugin-partials

Adds support for Partials (re-usable templates) to DocPad.
Other
29 stars 13 forks source link

doesn't work on windows #23

Open nfriedly opened 10 years ago

nfriedly commented 10 years ago

Hey, I notice that my site partials get rendered as if they were just .html rather than .html.eco when I'm on Windows, so I grabbed a copy of the partials plugin and sure enough, the tests fail on Windows (they all pass on my mac.)

Here's a full copy of the console output:

$ cake test
cake compile
cake install
npm install (for app)
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\cson requires coffee-script@'~1.7.1' bu
t will load
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\coffee-script,
npm WARN unmet dependency which is version 1.8.0
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\cson\node_modules\js2coffee requires co
ffee-script@'~1.7.1' but will load
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\coffee-script,
npm WARN unmet dependency which is version 1.8.0
npm install (for test)
npm install (for docpad tests)
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\cson requires coffee-script@'~1.7.1' bu
t will load
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\coffee-script,
npm WARN unmet dependency which is version 1.8.0
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\cson\node_modules\js2coffee requires co
ffee-script@'~1.7.1' but will load
npm WARN unmet dependency c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\coffee-script,
npm WARN unmet dependency which is version 1.8.0
coffee compile
npm test

> docpad-plugin-partials@2.9.1 test c:\Users\IBM_ADMIN\docpad-plugin-partials
> node ./out/partials.test.js

partials
partials > create
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docpad.org/donate
error: An error occured:
Error: Didn't place the skeleton as the desired structure already exists
  at c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\out\lib\docpad.js:4107:17
  at Object.cb [as oncomplete] (fs.js:168:19)
error: To report the above error, follow the guide at: http://docpad.org/bug-report
partials > create OK
partials > load plugin partials
partials > load plugin partials OK
partials > generate
partials > generate > action
partials > generate > action OK
partials > generate > results
partials > generate > results > same files
partials > generate > results > same files OK
partials > generate > results > same file content for: partials.html

actual:
<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- WITHOUT template data -->
<header>Hello World. Site date is defined no</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- WITHOUT template data and custom name -->
<header>Hello Partials!. Site date is defined no</header>

<!-- with template data via fuzzy -->
<header>Hello World. Site date is defined yes</header>

<!-- footer -->
<footer>Goodbye!</footer>

<!-- empty -->

<!-- With a partial containing the same partial -->
<header>Hello <header>Hello World. Site date is defined no</header>. Site date is defined no</header>

expected:
<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- with template data -->
<header>Hello World. Site date is defined yes</header>

<!-- WITHOUT template data -->
<header>Hello World. Site date is defined no</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- with template data and custom name -->
<header>Hello Partials!. Site date is defined yes</header>

<!-- WITHOUT template data and custom name -->
<header>Hello Partials!. Site date is defined no</header>

<!-- with template data via fuzzy -->
<header>Hello World. Site date is defined yes</header>

<!-- footer -->
<footer>Goodbye!</footer>

<!-- empty -->

<!-- With a partial containing the same partial -->
<header>Hello <header>Hello World. Site date is defined no</header>. Site date is defined no</header>

partials > generate > results > same file content for: partials.html ERR!
partials > generate > results ERR!
partials > generate ERR!
partials ERR!

FAILURE: 4/5 tests ran successfully; 1 failed, 0 incomplete, 1 errors

Error #1:
partials > generate > results > same file content for: partials.html
AssertionError: expected '<!-- with template data -->\n<header>Hello World. Site date is defined yes</header>\n\n<!-- with template data -->
\n<header>Hello World. Site date is defined yes</header>\n\n<!-- with template data -->\n<header>Hello World. Site date is defined yes</head
er>\n\n<!-- WITHOUT template data -->\n<header>Hello World. Site date is defined no</header>\n\n<!-- with template data and custom name -->\
n<header>Hello Partials!. Site date is defined yes</header>\n\n<!-- with template data and custom name -->\n<header>Hello Partials!. Site da
te is defined yes</header>\n\n<!-- with template data and custom name -->\n<header>Hello Partials!. Site date is defined yes</header>\n\n<!-
- WITHOUT template data and custom name -->\n<header>Hello Partials!. Site date is defined no</header>\n\n<!-- with template data via fuzzy
-->\n<header>Hello World. Site date is defined yes</header>\n\n<!-- footer -->\n<footer>Goodbye!</footer>\n\n<!-- empty -->\n\n\n<!-- With a
 partial containing the same partial -->\n<header>Hello <header>Hello World. Site date is defined no</header>. Site date is defined no</head
er>' to deeply equal '<!-- with template data -->\r\n<header>Hello World. Site date is defined yes</header>\r\n\r\n<!-- with template data -
->\r\n<header>Hello World. Site date is defined yes</header>\r\n\r\n<!-- with template data -->\r\n<header>Hello World. Site date is defined
 yes</header>\r\n\r\n<!-- WITHOUT template data -->\r\n<header>Hello World. Site date is defined no</header>\r\n\r\n<!-- with template data
and custom name -->\r\n<header>Hello Partials!. Site date is defined yes</header>\r\n\r\n<!-- with template data and custom name -->\r\n<hea
der>Hello Partials!. Site date is defined yes</header>\r\n\r\n<!-- with template data and custom name -->\r\n<header>Hello Partials!. Site d
ate is defined yes</header>\r\n\r\n<!-- WITHOUT template data and custom name -->\r\n<header>Hello Partials!. Site date is defined no</heade
r>\r\n\r\n<!-- with template data via fuzzy -->\r\n<header>Hello World. Site date is defined yes</header>\r\n\r\n<!-- footer -->\r\n<footer>
Goodbye!</footer>\r\n\r\n<!-- empty -->\r\n\r\n\r\n<!-- With a partial containing the same partial -->\r\n<header>Hello <header>Hello World.
 Site date is defined no</header>. Site date is defined no</header>'
  at EventEmitterGrouped.<anonymous> (c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\out\lib\testers.js:268:46)
  at ambi (c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\ambi\out\lib\ambi.js:57:27)
  at fire (c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\taskgroup\out\lib\taskgroup.js:384:27)
  at b (domain.js:183:18)
  at Domain.run (domain.js:123:23)
  at EventEmitterGrouped.Task.fire (c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\taskgroup\out\lib\taskgroup.j
s:398:25)
  at Object._onImmediate (c:\Users\IBM_ADMIN\docpad-plugin-partials\node_modules\docpad\node_modules\taskgroup\out\lib\taskgroup.js:414:26)
  at processImmediate [as _immediateCallback] (timers.js:345:15)

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

c:\Users\IBM_ADMIN\docpad-plugin-partials\Cakefile:99
      throw err;
            ^
Error: Process exited with error status code
  at ChildProcess.<anonymous> (c:\Users\IBM_ADMIN\docpad-plugin-partials\Cakefile:88:15)
  at ChildProcess.emit (events.js:98:17)
  at maybeClose (child_process.js:756:16)
  at Process.ChildProcess._handle.onexit (child_process.js:823:5)
nfriedly commented 10 years ago

(I believe that test failure is due to line-endings - it's expecting \n and getting \r\n)

nfriedly commented 10 years ago

I figured out the other part of the issue: on windows, getFilesAtPath('projects/') doesn't find anything because windows uses backslashes. Fortunately getFilesAtPath('projects') works.

And then the empty collection causes some bug that results in the template outputting the source instead of the rendered HTML. I haven't tracked that one down yet, but I think I'm going to stop here since it's working for me now.