Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Commit

Permalink
Add simple require smoke-test
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Mar 31, 2017
1 parent fe74b77 commit 6e363e4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ install:
- $PKG_CMD install
script:
- 'if [ -n "${LINT-}" ]; then $PKG_CMD run lint ; fi'
- 'if [ -z "${LINT-}" ]; then $PKG_CMD run test-ci ; fi'
- 'if [ -n "${SMOKE_TEST-}" ]; then node scripts/smoke-test.js ; fi'
- 'if [ -z "${LINT-}" ] && [ -z "${SMOKE_TEST-}" ]; then $PKG_CMD run test-ci ; fi'
matrix:
fast_finish: true
exclude:
Expand All @@ -38,5 +39,7 @@ matrix:
include:
- node_js: "node"
env: LINT=true PKG_CMD="npm"
- node_js: "node"
env: SMOKE_TEST=true PKG_CMD="npm"

after_success: 'if [ -z "${LINT-}" ]; then npm run coverage-ci ; fi'
after_success: 'if [ -z "${LINT-}" ] && [ -z "${SMOKE_TEST-}" ]; then npm run coverage-ci ; fi'
44 changes: 44 additions & 0 deletions scripts/smoke-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const fs = require("fs-extra");
const execSync = require("child_process").execSync;
const path = require("path");
const pkg = require("../package.json");

let errorOccurred = false;

const tempFolderPath = path.join(__dirname, "../tmp");
const packPath = path.join(__dirname, `../babel-preset-env-${pkg.version}.tgz`);

try {
console.log("Creating package");
execSync("npm pack");

console.log("Setting up smoke test");
fs.ensureDir(tempFolderPath);

fs.writeFileSync(
path.join(tempFolderPath, "package.json"),
"{\n \"name\": \"babel-preset-env-smoke-test\",\n \"version\": \"1.0.0\",\n \"private\": true\n}\n"
);

fs.writeFileSync(
path.join(tempFolderPath, "index.js"),
"require(\"babel-preset-env\");\n"
);

process.chdir(tempFolderPath);

console.log("Running smoke test");
execSync(`npm install ../babel-preset-env-${pkg.version}.tgz`);
execSync("node index.js");
} catch (e) {
errorOccurred = true;
}

console.log("Cleaning up");
if (fs.existsSync(tempFolderPath)) {
fs.removeSync(tempFolderPath);
}

fs.removeSync(packPath);

process.exit(errorOccurred ? 1 : 0);

0 comments on commit 6e363e4

Please sign in to comment.