cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorin Beer <lorin.b...@gmail.com>
Subject Re: NodeJS Hooks dependencies?
Date Tue, 05 Aug 2014 21:22:55 GMT
a suggestion:

as part of the hook script, have it attempt an npm install iff the
dependencies are not present. You can hide the require calls in a
try/catch, if caught, then run an install script in the relevant hook
directories.

If admin privileges are required for the install, prompt for credentials,
or tell the user to change the directory permissions...

Don't know about 'best practice', but it's light weight and doesn't force
the user to execute an intermediate install step.



On Tue, Aug 5, 2014 at 1:00 PM, Carlos Santana <csantana23@gmail.com> wrote:

> I'm writing new cordova hooks, and decided to do them in nodejs
>
> First problem I hit was dependencies for the hook scripts:
> so far I have two scripts:
> cordovaUserProject/hook/before_prepare/wl_b_prepare.js
> cordovaUserProject/hook/after_compile/wl_a_compile.js
>
> I have both starting like this:
> #!/usr/bin/env node
>
> var shell = require('shelljs'),
> nopt  = require('nopt');
>
> shell.echo('Running Worklight Cordova Hook');
>
>
> I get errors because it can't find dependencies 'shelljs' and 'nopt'
>
> To resolve this I would need the user or another hook before this one to
> install the node_modules in one of these places
>
> cordovaUserProject/node_modules/
> cordovaUserProject/hook/node_modules/
> cordovaUserProject/hook/before_prepare/node_modules/
> cordovaUserProject/hook/after_compile/node_modules/
>
> What would be a best practice?
> Who get's to install? (user or me)
> Where to install?
>
>
>
> --
> Carlos Santana
> <csantana23@gmail.com>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message