Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno hydrate using deno cache #585

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/invoke-lambda/run-in-deno.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ let spawn = require('./spawn')

module.exports = function runInNode (params, callback) {
let deno = join(__dirname, 'runtimes', 'deno.js')
let root = params.options.env.LAMBDA_TASK_ROOT
params.options.env = {...params.options.env, 'DENO_DIR': join(root, 'vendor', '.deno_cache')}
spawn({
command: 'deno',
args: [
'run', '-A', '--unstable', '--reload', deno
'run', '-A', '--unstable', deno
],
...params,
}, callback)
Expand Down
12 changes: 12 additions & 0 deletions src/lib/maybe-hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ module.exports = function maybeHydrate (inventory, callback) {
}
else callback()
},
function _deno(callback) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this block needs to be linted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 👍

if(inv.lambdasBySrcDir[path] !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is unnecessary, this function only got called on Lambdas that exist in the project inventory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.. the tests fail without that block

/Users/martinhicks/Projects/sandbox/src/lib/maybe-hydrate.js:95
            let isDenoRuntime = (inv.lambdasBySrcDir[path].config.runtime === 'deno')
                                                           ^

TypeError: Cannot read property 'config' of undefined

Screenshot 2021-05-28 at 13 28 48

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, happens when the path is the shared or views dir path. Have added that to the isDenoRuntime condition

let isDenoRuntime = (inv.lambdasBySrcDir[path].config.runtime === 'deno')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only check you need to run to install!

if(isDenoRuntime) {
install(callback)
}
else callback()

}
else callback()

}
], callback)
}
})
Expand Down