<commit_before>'use strict';

var processUtils = require('./process'),
	Steppy = require('twostep').Steppy,
	path = require('path'),
	url = require('url'),
	fs = require('fs');

exports.install = function(options, callback) {
	processUtils.exec('npm install --production', options, callback);
};

exports.prune = function(options, callback) {
	processUtils.exec('npm prune', options, callback);
};

exports.sync = function(options, callback) {
	Steppy(
		function() {
			exports.prune(options, this.slot());
		},
		function() {
			exports.install(options, this.slot());
		},
		callback
	);
};

exports.download = function(targetPackage, dest, options, callback) {
	Steppy(
		function() {
			if (/^https?:/.test(targetPackage) && options.auth) {
				var parsedUrl = url.parse(targetPackage);
				parsedUrl.auth = options.auth;

				targetPackage = url.format(parsedUrl);
			}

			var dir = path.dirname(dest);

			this.pass(dir);

			var packSlot = this.slot();
			var packOutData = '';
			var packErrData = '';

			var packSpawn = processUtils.exec(
				'npm pack ' + targetPackage,
				{cwd: dir},
				function(err) {
					if (err && packErrData) {
						err.message += '\nstderr: ' + packErrData;
					}

					packSlot(err, packOutData);
				}
			);

			packSpawn.stdout.on('data', function(data) {
				packOutData += data;
			});

			packSpawn.stderr.on('data', function(data) {
				packErrData += data;
			});
		},
		function(err, dir, packOutData) {
			var tarballName = packOutData.replace(/\n$/, '');

			fs.rename(
				path.join(dir, tarballName),
				dest,
				this.slot()
			);
		},
		function() {
			this.pass(null);
		},
		callback
	);
};<commit_msg>download package to current directory and move it to target directory<commit_after>'use strict';

var processUtils = require('./process'),
	Steppy = require('twostep').Steppy,
	path = require('path'),
	url = require('url'),
	fse = require('fs-extra');

exports.install = function(options, callback) {
	processUtils.exec('npm install --production', options, callback);
};

exports.prune = function(options, callback) {
	processUtils.exec('npm prune', options, callback);
};

exports.sync = function(options, callback) {
	Steppy(
		function() {
			exports.prune(options, this.slot());
		},
		function() {
			exports.install(options, this.slot());
		},
		callback
	);
};

exports.download = function(targetPackage, dest, options, callback) {
	Steppy(
		function() {
			if (/^https?:/.test(targetPackage) && options.auth) {
				var parsedUrl = url.parse(targetPackage);
				parsedUrl.auth = options.auth;

				targetPackage = url.format(parsedUrl);
			}

			var dir = path.dirname(dest);

			this.pass(dir);

			var packSlot = this.slot();
			var packOutData = '';
			var packErrData = '';

			var packSpawn = processUtils.exec(
				'npm pack ' + targetPackage,
				{},
				function(err) {
					if (err && packErrData) {
						err.message += '\nstderr: ' + packErrData;
					}

					packSlot(err, packOutData);
				}
			);

			packSpawn.stdout.on('data', function(data) {
				packOutData += data;
			});

			packSpawn.stderr.on('data', function(data) {
				packErrData += data;
			});
		},
		function(err, dir, packOutData) {
			var tarballName = packOutData.trim();

			fse.move(
				path.join(process.cwd(), tarballName),
				dest,
				this.slot()
			);
		},
		function() {
			this.pass(null);
		},
		callback
	);
};
{'fraction_non_alphanumeric': 0.16824644549763032, 'fraction_numerical': 0.0, 'mean_word_length': 3.3743523316062176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4464323', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1121, 'n_words': 220}