Skip to content

Commit

Permalink
Accept .cjs (Commonjs) file for the db (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedemp authored Feb 22, 2023
1 parent 7310b2b commit 39f615c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
37 changes: 37 additions & 0 deletions __fixtures__/seed.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Need some fake data for the gzip test to work
module.exports = function () {
return {
posts: [
{
id: 1,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
{
id: 2,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
{
id: 3,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
{
id: 4,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
{
id: 5,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
{
id: 6,
content:
"Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!",
},
],
}
}
11 changes: 11 additions & 0 deletions __tests__/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ describe('cli', () => {
})
})

describe('seed.cjs', () => {
beforeEach((done) => {
child = cli(['../../__fixtures__/seed.cjs'])
serverReady(PORT, done)
})

test('should support CommonJS file', (done) => {
request.get('/posts').expect(200, done)
})
})

describe('remote db', () => {
beforeEach((done) => {
child = cli(['https://jsonplaceholder.typicode.com/db'])
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function FILE(s) {
}

function JS(s) {
return !URL(s) && /\.js$/.test(s)
return !URL(s) && /\.c?js$/.test(s)
}

function URL(s) {
Expand Down

0 comments on commit 39f615c

Please sign in to comment.