diff --git a/CHANGELOG.md b/CHANGELOG.md index cde6af7..d087599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,6 @@ ### 1.0.1 - Fix inaccurate (wrong) docs + + ### 1.0.2 + - If target directory does not exist, create it diff --git a/package.json b/package.json index 57e019a..10de13f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "get-selenium", - "version": "1.0.1", + "version": "1.0.2", "description": "Make sure you've got the selenium jar and the chromedriver executable", "main": "lib/index.js", "scripts": { @@ -26,6 +26,7 @@ "extract-zip": "^1.5.0", "file-exists": "^1.0.0", "md5-file": "^3.1.1", + "mkdirp": "^0.5.1", "request": "^2.73.0" }, "devDependencies": { @@ -44,10 +45,10 @@ "eslint-plugin-react": "^5.2.2", "expect.js": "^0.3.1", "glob": "^7.0.5", - "mkdirp": "^0.5.1", "mocha": "^2.5.3", "mocha-lcov-reporter": "^1.2.0", "nyc": "^7.0.0", + "rimraf": "^2.5.3", "tmp": "0.0.28" }, "files": [ diff --git a/src/index.js b/src/index.js index 8a28606..1ee98a5 100644 --- a/src/index.js +++ b/src/index.js @@ -2,15 +2,18 @@ import 'babel-polyfill'; import bluebird from 'bluebird'; import glob from 'glob'; import path from 'path'; +import mkdirp from 'mkdirp'; import selenium from './selenium'; import chromedriver from './chromedriver'; import { unlink } from './util'; const globber = bluebird.promisify(glob); +const makeDir = bluebird.promisify(mkdirp); /* eslint-disable no-console, func-names */ const ensure = async function(target) { + await makeDir(target); console.log('Getting selenium'); await selenium(target); console.log('Got selenium'); diff --git a/test/ensure.spec.js b/test/ensure.spec.js index 6fdba0e..2ccc64e 100644 --- a/test/ensure.spec.js +++ b/test/ensure.spec.js @@ -5,6 +5,7 @@ import path from 'path'; import mkdirp from 'mkdirp'; import fs from 'fs'; import glob from 'glob'; +import rmrf from 'rimraf'; import { ensure, @@ -23,6 +24,11 @@ before(async function() { //tmpPath = path.join('/', 'home', 'ivarni', 'Downloads'); tmpPath = path.join(await dir(), 'selenium'); await makeDir(tmpPath); + console.log(tmpPath) +}); + +after(done => { + rmrf(tmpPath, done); }); describe('ensure', function() { @@ -33,10 +39,6 @@ describe('ensure', function() { await ensure(tmpPath); }); - after(() => { - // get rid of the tmp dir - }); - it('downloads selenium and chromedriver', async function() { await stat(path.join(tmpPath, 'selenium.jar')); const files = await globber(path.join(tmpPath, 'chromedriver*')); @@ -48,6 +50,15 @@ describe('ensure', function() { expect(files.length).to.be(0); }); + describe('if target directory does not exist', async function() { + + it('creates it', async function() { + await bluebird.promisify(rmrf)(tmpPath); + await ensure(tmpPath); + }); + + }) + }); describe('update', function() {