How to use safeps - 7 common examples

To help you get started, we’ve selected a few safeps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bevry-archive / feedr / source / index.js View on Github external
// Extend and dereference our configuration
		this.config = extendr.deep(
			{
				log: null,
				cache: 1000 * 60 * 60 * 24, // one day by default
				tmpPath: null,
				requestOptions: null,
				plugins: null
			},
			this.config || {},
			config
		)

		// Get the temp path right away
		safeps.getTmpPath(function(err, tmpPath) {
			if (err) {
				console.error(err)
			} else {
				me.config.tmpPath = tmpPath
			}
		})
	}
github bevry / lazy-require / source / index.js View on Github external
error = new Error(
			'lazy-require: cannot save the module as `opts.cwd` did not contain a `package.json` file'
		)
	}

	// Install
	else {
		// Arguments
		const args = ['npm', 'install', name]
		if (opts.save === true) {
			args.push('--save')
			opts.save = null // {delete opts.save} is very slow
		}

		// Install
		safeps.spawn(args, opts, function(err) {
			// Check
			if (err) return next(err)

			// Try to load the module
			lazyRequire.require(name, opts, next)
		})

		// Exit
		return null
	}

	// Complete
	return complete(error, null, next)
}
github bevry / lazy-require / source / index.js View on Github external
lazyRequire.canSyncInstall = function canSyncInstall(opts, next) {
	// Prepare
	;[opts, next] = extractOptsAndCallback(opts, next)
	let result = safeps.hasSpawnSync()
	let error = null

	// Fetch
	if (result instanceof Error) {
		error = result
		result = null
	}

	// Complete
	return complete(error, result, next)
}
github bevry / lazy-require / source / index.js View on Github external
error = new Error(
			'lazy-require: cannot save the module as `opts.cwd` did not contain a `package.json` file'
		)
	}

	// Install
	else {
		// Arguments
		const args = ['npm', 'install', name]
		if (opts.save === true) {
			args.push('--save')
			opts.save = null // {delete opts.save} is very slow
		}

		// Install
		const spawnResult = safeps.spawnSync(args, opts)
		if (spawnResult instanceof Error) {
			error = spawnResult
		} else {
			// Exit
			return lazyRequire.require(name, opts, next)
		}
	}

	// Complete
	return complete(error, null, next)
}
github bevry / boundation / source / fs.js View on Github external
return new Promise(function(resolve, reject) {
		safeps.spawn(command, opts, function(err, stdout) {
			if (err)
				return reject(new Errlop(`spawn failed: ${command.join(' ')}`, err))
			return resolve(stdout)
		})
	})
}
github nfriedly / nfriedly.com / node_modules / docpad / out / lib / util.js View on Github external
startLocalDocPadExecutable: function(next) {
      var args, command;
      args = process.argv.slice(2);
      command = ['node', docpadUtil.getLocalDocPadExecutable()].concat(args);
      return require('safeps').spawn(command, {
        stdio: 'inherit'
      }, function(err) {
        var message;
        if (err) {
          if (next) {
            return next(err);
          } else {
            message = 'An error occured within the child DocPad instance: ' + err.message + '\n';
            return process.stderr.write(message);
          }
        } else {
          return typeof next === "function" ? next() : void 0;
        }
      });
    },
    getBasename: function(filename) {
github bevry / boundation / source / fs.js View on Github external
return new Promise(function(resolve, reject) {
		safeps.exec(command, opts, function(err, stdout) {
			if (err) return reject(new Errlop(`exec failed: ${command}`, err))
			return resolve(stdout)
		})
	})
}

safeps

Work with processes safely and easily with Node.js

Artistic-2.0
Latest version published 10 months ago

Package Health Score

61 / 100
Full package analysis