Skip to content

Instantly share code, notes, and snippets.

@jdalton jdalton/amd.sh
Last active Aug 10, 2016

Embed
What would you like to do?
node ../lodash-cli/bin/lodash modularize exports=amd -o ./ && node ../lodash-cli/bin/lodash exports=amd -d -o ./main.js
node ../lodash-cli/bin/lodash modularize exports=es -o ./
npm run build
node ../lodash-cli/bin/lodash -o ./dist/lodash.js
node ../lodash-cli/bin/lodash core -o ./dist/lodash.core.js
node ../lodash-cli/bin/lodash modularize exports=npm -o ./
node ../lodash-cli/bin/lodash modularize exports=node -o ./foo && node ../lodash-cli/bin/lodash -d -o ./foo/lodash.js
'use strict';
var util = require('./lib/util.js'),
fs = util.fs,
path = util.path;
var _ = require('lodash'),
glob = require('glob'),
moment = require('moment'),
ncp = require('ncp').ncp;
var cwd = process.cwd();
var packages = _.transform(glob.sync(path.join(cwd, 'lodash.*')), function(result, pathname) {
var stat = fs.statSync(path.join(pathname, 'index.js'));
if (!moment(stat.mtime).isSame(stat.birthtime)) {
result[path.basename(pathname)] = require(path.join(pathname, 'package.json'));
}
}, {});
var grouped = _.groupBy(packages, 'version');
_.forOwn(grouped, function(packages, version) {
var pathname = path.join(cwd, version);
if (!fs.existsSync(pathname)) {
fs.mkdirpSync(pathname);
}
_.each(packages, function(pkg) {
var source = path.join(cwd, pkg.name),
destination = path.join(pathname, pkg.name);
ncp(source, destination, function (err) {
if (err) {
console.error(err);
return;
}
// console.log('copied ' + pkg.name + ' to ' + path.join(version, pkg.name));
});
});
});
'use strict';
var _ = require('lodash'),
childProcess = require('child_process'),
execSync = childProcess.execSync,
semver = require('semver'),
spawn = childProcess.spawn;
var branch = 'npm-packages';
var reLine = /^.*$/gm;
var output = execSync('git log ' + branch + ' --pretty=format:"%s | %h"').toString();
var pairs = _.map(output.match(reLine), function(value) {
var pair = _.map(_.trim(value, '"\'').split('|'), _.trim);
pair[0] = _.result(/\d+(?:\.\d+)*/.exec(pair[0]), 0, '');
return pair;
});
pairs = _.filter(pairs, '0');
pairs.sort(function(a, b) {
return semver.gt(a[0], b[0]) ? 1 : (semver.lt(a[0], b[0]) ? -1 : 0);
});
pairs = pairs.map(function(pair) {
var tag = pair[0] + (branch == 'master' ? '' : '-' + branch);
return [
//'git checkout ' + parts[0] + '-npm-packages && git commit --amend --no-edit --date "`date`"'//,
'git tag -f -a -m ' + tag + ' "' + tag + '" ' + pair[1],
'git push -f origin ' + tag
];
});
_.each(pairs, function(pair, index) {
_.each(pair, function(command) {
_.delay(function() {
console.log(command)
execSync(command);
}, 1000 * index);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.