[
https://issues.apache.org/jira/browse/CB-8754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14383931#comment-14383931
]
ASF GitHub Bot commented on CB-8754:
------------------------------------
Github user TimBarham commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/194#discussion_r27299568
--- Diff: cordova-lib/src/util/npm-helper.js ---
@@ -0,0 +1,76 @@
+/**
+ 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.
+ */
+
+// Helper methods to help keep npm operations separated.
+
+var npm = require('npm'),
+ Q = require('q'),
+ cachedSettings = null,
+ cachedSettingsValues = null;
+
+/**
+ * @description Calls npm.load, then initializes npm.config with the
specified settings. Then executes a chain of
+ * promises that rely on those npm settings, then restores npm settings
back to their previous value. Use this rather
+ * than passing settings to npm.load, since that only works the first time
you try to load npm.
+ * @param {Object} settings
+ * @param {Function} promiseChain
+ */
+function loadWithSettingsThenRestore(settings, promiseChain) {
+ return
loadWithSettings(settings).then(promiseChain).then(restoreSettings);
--- End diff --
Yes, indeed it should ... good point :)
> Auto-restoring a plugin fails when adding a platform
> ----------------------------------------------------
>
> Key: CB-8754
> URL: https://issues.apache.org/jira/browse/CB-8754
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaLib
> Affects Versions: Master
> Reporter: Tim Barham
> Assignee: Tim Barham
> Original Estimate: 5h
> Remaining Estimate: 5h
>
> Start with a blank Cordova app, then enter the following:
> {noformat}
> cordova plugin add org.apache.cordova.camera --save
> cordova plugin remove org.apache.cordova.camera
> cordova platform add browser
> {noformat}
>
> The final step should restore the camera plugin, but it fails with the
> following exception:
> {noformat}
> TypeError: Cannot read property 'latest' of undefined
> at next
> (D:\GIT\Cordova\cordova-lib\cordova-lib\node_modules\npm\lib\cache.js:694:35)
> at
> D:\GIT\Cordova\cordova-lib\cordova-lib\node_modules\npm\lib\cache.js:682:5
> at RegClient.get_
> (D:\GIT\Cordova\cordova-lib\cordova-lib\node_modules\npm\node_modules\npm-registry-client\lib\get.js:105:14)
> at RegClient.<anonymous>
> (D:\GIT\Cordova\cordova-lib\cordova-lib\node_modules\npm\node_modules\npm-registry-client\lib\get.js:41:12)
> at fs.js:336:14
> at
> D:\GIT\Cordova\cordova-lib\cordova-lib\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:103:5
> at FSReqWrap.oncomplete (fs.js:99:15)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]