From d457af8d5198f8c878c768e0abee371ed18f2e4b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 14 Jan 2018 18:14:07 -0500 Subject: [PATCH] update test --- .../routes/api/blog/{index.js => contents.js} | 0 test/app/routes/blog/index.html | 2 +- test/common/test.js | 43 +++++++++---------- 3 files changed, 21 insertions(+), 24 deletions(-) rename test/app/routes/api/blog/{index.js => contents.js} (100%) diff --git a/test/app/routes/api/blog/index.js b/test/app/routes/api/blog/contents.js similarity index 100% rename from test/app/routes/api/blog/index.js rename to test/app/routes/api/blog/contents.js diff --git a/test/app/routes/blog/index.html b/test/app/routes/blog/index.html index 16ff29e..affe73f 100644 --- a/test/app/routes/blog/index.html +++ b/test/app/routes/blog/index.html @@ -32,7 +32,7 @@ }, preload({ params, query }) { - return fetch(`/api/blog`).then(r => r.json()).then(posts => { + return fetch(`/api/blog/contents`).then(r => r.json()).then(posts => { return { posts }; }); } diff --git a/test/common/test.js b/test/common/test.js index 3d6e386..4056bee 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -334,34 +334,24 @@ function run(env) { // Pages that should show up in the extraction directory. const expectedPages = [ 'index.html', - 'api/index.html', - 'about/index.html', - 'api/about/index.html', - 'slow-preload/index.html', - 'api/slow-preload/index.html', 'blog/index.html', - 'api/blog/index.html', - 'blog/a-very-long-post/index.html', - 'api/blog/a-very-long-post/index.html', - 'blog/how-can-i-get-involved/index.html', - 'api/blog/how-can-i-get-involved/index.html', - 'blog/how-is-sapper-different-from-next/index.html', - 'api/blog/how-is-sapper-different-from-next/index.html', - 'blog/how-to-use-sapper/index.html', - 'api/blog/how-to-use-sapper/index.html', - 'blog/what-is-sapper/index.html', - 'api/blog/what-is-sapper/index.html', - 'blog/why-the-name/index.html', - 'api/blog/why-the-name/index.html', + + 'api/blog/contents', + 'api/blog/a-very-long-post', + 'api/blog/how-can-i-get-involved', + 'api/blog/how-is-sapper-different-from-next', + 'api/blog/how-to-use-sapper', + 'api/blog/what-is-sapper', + 'api/blog/why-the-name', 'favicon.png', 'global.css', @@ -408,12 +398,19 @@ function run(env) { function exec(cmd) { return new Promise((fulfil, reject) => { - require('child_process').exec(cmd, (err, stdout, stderr) => { - process.stdout.write(stdout); - process.stderr.write(stderr); + const parts = cmd.split(' '); + const proc = require('child_process').spawn(parts.shift(), parts); - if (err) return reject(err); - fulfil(); + proc.stdout.on('data', data => { + process.stdout.write(data); }); + + proc.stderr.on('data', data => { + process.stderr.write(data); + }); + + proc.on('error', reject); + + proc.on('close', () => fulfil()); }); }