cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manish varma <mvdmani...@gmail.com>
Subject Re: [GitHub] cordova-lib pull request: CB-9858 Cordova Fetch Work
Date Wed, 09 Mar 2016 08:39:19 GMT
cool

On Wed, Mar 9, 2016 at 12:53 PM, stevengill <git@git.apache.org> wrote:

> Github user stevengill commented on a diff in the pull request:
>
>     https://github.com/apache/cordova-lib/pull/407#discussion_r55480177
>
>     --- Diff: cordova-fetch/index.js ---
>     @@ -0,0 +1,176 @@
>     +/**
>     + Licensed to the Apache Software Foundation (ASF) under one
>     + or more contributor license agreements.  See the NOTICE file
>     + distributed with this work for additional information
>     + regarding copyright ownership.  The ASF licenses this file
>     + to you under the Apache License, Version 2.0 (the
>     + 'License'); you may not use this file except in compliance
>     + with the License.  You may obtain a copy of the License at
>     +
>     + http://www.apache.org/licenses/LICENSE-2.0
>     +
>     + Unless required by applicable law or agreed to in writing,
>     + software distributed under the License is distributed on an
>     + 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>     + KIND, either express or implied.  See the License for the
>     + specific language governing permissions and limitations
>     + under the License.
>     + */
>     +
>     +var Q = require('q');
>     +var shell = require('shelljs');
>     +var superspawn = require('cordova-common').superspawn;
>     +var events = require('cordova-common').events;
>     +var depls = require('dependency-ls');
>     +var path = require('path');
>     +var fs = require('fs');
>     +var CordovaError = require('cordova-common').CordovaError;
>     +var isUrl = require('is-url');
>     +
>     +/*
>     + * A module that npm installs a module from npm or a git url
>     + *
>     + * @param {String} target   the packageID or git url
>     + * @param {String} dest     destination of where to install the module
>     + * @param {Object} opts     [opts={save:true}] options to pass to
> fetch module
>     + *
>     + * @return {String||Promise}    Returns string of the absolute path
> to the installed module.
>     + *
>     + */
>     +module.exports = function(target, dest, opts) {
>     +    var fetchArgs = ['install'];
>     +    opts = opts || {};
>     +    var tree1;
>     +
>     +    if(!shell.which('npm')) {
>     +        return Q.reject(new CordovaError('"npm" command line tool is
> not installed: make sure it is accessible on your PATH.'));
>     +    }
>     +
>     +    if(dest && target) {
>     +        //add target to fetchArgs Array
>     +        fetchArgs.push(target);
>     +
>     +        //append node_modules to dest if it doesn't come included
>     +        if (path.basename(dest) !== 'node_modules') {
>     +            dest = path.resolve(path.join(dest, 'node_modules'));
>     +        }
>     +
>     +        //create dest if it doesn't exist
>     +        if(!fs.existsSync(dest)) {
>     +            shell.mkdir('-p', dest);
>     +        }
>     +
>     +    } else return Q.reject(new CordovaError('Need to supply a target
> and destination'));
>     +
>     +    //set the directory where npm install will be run
>     +    opts.cwd = dest;
>     --- End diff --
>
>     Yup! Pass everything to superspawn that fetch was passed. Add the cwd
> to opts though.
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
> For additional commands, e-mail: dev-help@cordova.apache.org
>
>


-- 
Regards
Manish Varma D
+91-9538612399
LinkedIn: //in.linkedin.com/pub/manish-varma-d/86/66a/ab
Think Green: Please consider the environment before printing this e-mail.Privy
Notice: This is a confidential email. If you are not the expected
recipient, we alert you that this email has reached you by error and
disclosing of the contents to any other source is strictly prohibited. If
you have received this email by error, you are requested to acknowledge and
delete the message immediately.

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