Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cache:
- node_modules

node_js:
- "0.10"
- "0.12"
- "4"
- stable
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<p align="center">
<a href="https://www.npmjs.com/package/lerna"><img alt="NPM Status" src="https://img.shields.io/npm/v/lerna.svg?style=flat"></a>
<a href="https://circleci.com/gh/lerna/lerna"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/lerna/lerna/master.svg?style=flat&label=circle"></a>
<a href="https://travis-ci.org/lerna/lerna"><img alt="Travis Status" src="https://img.shields.io/travis/lerna/lerna/master.svg?style=flat&label=travis"></a>
<a href="https://slack.lernajs.io/"><img alt="Slack Status" src="https://slack.lernajs.io/badge.svg"></a>
</p>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"progress": "^1.1.8",
"rimraf": "^2.4.4",
"semver": "^5.1.0",
"signal-exit": "^2.1.2"
"signal-exit": "^2.1.2",
"sync-exec": "^0.6.2"
},
"bin": {
"lerna": "./bin/lerna.js"
Expand Down
13 changes: 10 additions & 3 deletions src/ChildProcessUtilities.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import child from "child_process";
import objectAssign from "object-assign";
import syncExec from "sync-exec";

export default class ChildProcessUtilities {
static exec(command, opts, callback) {
Expand All @@ -21,9 +22,15 @@ export default class ChildProcessUtilities {
}

static execSync(command) {
return child.execSync(command, {
encoding: "utf8"
}).trim();
if (child.execSync) {
return child.execSync(command, {
encoding: "utf8"
}).trim();
} else {
return syncExec(command, {
encoding: "utf8"
}).stdout.trim();
}
}

static spawn(command, args, opts, callback) {
Expand Down
71 changes: 37 additions & 34 deletions test/UpdatedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import assert from "assert";
import child from "child_process";
import path from "path";
import fs from "fs";
import syncExec from "sync-exec";

import UpdatedCommand from "../src/commands/UpdatedCommand";
import exitWithCode from "./_exitWithCode";
import initFixture from "./_initFixture";
import logger from "../src/logger";
import stub from "./_stub";

const execSync = (child.execSync || syncExec);

describe("UpdatedCommand", () => {

/** =========================================================================
Expand All @@ -23,10 +26,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {});

Expand All @@ -46,10 +49,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes with --force-publish *", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {
forcePublish: "*"
Expand All @@ -71,10 +74,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes with --force-publish [package,package]", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {
forcePublish: "package-2,package-4"
Expand Down Expand Up @@ -103,11 +106,11 @@ describe("UpdatedCommand", () => {
};
fs.writeFileSync(lernaJsonLocation, JSON.stringify(lernaJson, null, 2));

child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-2/ignored-file"));
child.execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/ignored-file"));
execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {});

Expand Down Expand Up @@ -139,10 +142,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {});

Expand All @@ -162,10 +165,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes with --force-publish *", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {
forcePublish: "*"
Expand All @@ -187,10 +190,10 @@ describe("UpdatedCommand", () => {
});

it("should list changes with --force-publish [package,package]", done => {
child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-4/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-4/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {
forcePublish: "package-2"
Expand Down Expand Up @@ -219,11 +222,11 @@ describe("UpdatedCommand", () => {
};
fs.writeFileSync(lernaJsonLocation, JSON.stringify(lernaJson, null, 2));

child.execSync("git tag v1.0.0");
child.execSync("touch " + path.join(testDir, "packages/package-2/ignored-file"));
child.execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
child.execSync("git add -A");
child.execSync("git commit -m 'Commit'");
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/ignored-file"));
execSync("touch " + path.join(testDir, "packages/package-3/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {});

Expand Down
3 changes: 2 additions & 1 deletion test/_initFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import rimraf from "rimraf";
import child from "child_process";
import path from "path";
import cpr from "cpr";
import syncExec from "sync-exec";

const tmpDir = path.resolve(__dirname, "../tmp");
const originalCwd = process.cwd();
Expand Down Expand Up @@ -29,7 +30,7 @@ export default function initFixture(fixturePath, callback) {
}, err => {
if (err) return callback(err);
process.chdir(testDir);
child.execSync("git init . && git add -A && git commit -m 'Init commit'");
(child.execSync || syncExec)("git init . && git add -A && git commit -m 'Init commit'");
callback();
});

Expand Down