Comparing version 1.0.1 to 1.1.0
@@ -754,3 +754,3 @@ /************************************************************************************************************ | ||
*/ | ||
Registry.prototype.erase = function erase (cb) { | ||
Registry.prototype.clear = function clear (cb) { | ||
@@ -767,2 +767,3 @@ if (typeof cb !== 'function') | ||
env: process.env, | ||
stdio: [ 'ignore', 'pipe', 'pipe' ] | ||
}) | ||
@@ -798,2 +799,55 @@ , error = null // null means no error previously reported. | ||
/** | ||
* Alias for the clear method to keep it backward compatible. | ||
* @method | ||
* @deprecated Use {@link Registry#clear} or {@link Registry#destroy} in favour of this method. | ||
* @param {function (err)} cb - callback function | ||
* @param {error=} cb.err - error object or null if successful | ||
* @returns {Registry} this registry key object | ||
*/ | ||
Registry.prototype.erase = Registry.prototype.clear; | ||
/** | ||
* Delete this key and all subkeys from the registry. | ||
* @param {function (err)} cb - callback function | ||
* @param {error=} cb.err - error object or null if successful | ||
* @returns {Registry} this registry key object | ||
*/ | ||
Registry.prototype.destroy = function destroy (cb) { | ||
if (typeof cb !== 'function') | ||
throw new TypeError('must specify a callback'); | ||
var args = ['DELETE', this.path, '/f'] | ||
, proc = spawn('REG', args, { | ||
cwd: undefined, | ||
env: process.env, | ||
stdio: [ 'ignore', 'pipe', 'pipe' ] | ||
}) | ||
, error = null // null means no error previously reported. | ||
proc.on('close', function (code) { | ||
if(error) { | ||
return; | ||
} else if (code !== 0) { | ||
log('process exited with code ' + code); | ||
cb(mkErrorMsg("DELETE", code, output), null); | ||
} else { | ||
cb(null); | ||
} | ||
}); | ||
proc.stdout.on('data', function (data) { | ||
// simply discard output | ||
log(''+data); | ||
}); | ||
proc.on('error', function(err) { | ||
error = err; | ||
cb(err); | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Create this registry key. Note that this is a no-op if the key already exists. | ||
@@ -800,0 +854,0 @@ * @param {function (err)} cb - callback function |
{ | ||
"name": "winreg", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "provides access to the windows registry through the REG tool", | ||
@@ -5,0 +5,0 @@ "main": "lib/registry.js", |
20
test.js
@@ -15,2 +15,6 @@ | ||
}) | ||
, r3 = new Registry({ | ||
hive: Registry.HKCU, | ||
key: '\\Software\\AAA_' + new Date().toISOString() | ||
}) | ||
@@ -56,2 +60,18 @@ // get parent key | ||
// create key | ||
r3 | ||
. create(function (err) { | ||
if (!err) | ||
console.log('key created'); | ||
// delete key | ||
r3 | ||
. destroy(function (err) { | ||
if (!err) | ||
console.log('key deleted'); | ||
}) | ||
}) | ||
; | ||
}) | ||
@@ -58,0 +78,0 @@ ; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34675
878
10