<commit_before># fixture-dir [![Build status](https://travis-ci.org/twolfson/fixture-dir.png?branch=master)](https://travis-ci.org/twolfson/fixture-dir)

Create/copy directory to temporary directory

This was built for quickly setting up/tearing down directories that originate from tests but should not contaminate the repo. Previous to this repo's creation, I have used this pattern in [foundry-release-git][] and [sexy-bash-prompt][].

[foundry-release-git]: https://github.com/twolfson/foundry-release-git/blob/1.0.1/test/utils/fixtures.js
[sexy-bash-prompt]: https://github.com/twolfson/sexy-bash-prompt/blob/0.21.0/test/prompt_test.sh#L8-L19

A mocha flavor, [mocha-fixture-dir][], is available for automatic directory cleanup.

[mocha-fixture-dir]: https://github.com/twolfson/mocha-fixture-dir

## Getting Started
Install the module with: `npm install fixture-dir`

```javascript
// Generate a tmp namespace for our tests
var exec = require('child_process').exec;
var FixtureDir = require('fixture-dir');
var fixtureDir = new FixtureDir('my-node-module-tests');

// Inside of our tests, copy over folder contents and interact with them
before(function () {
  // Create a `git-log` folder with the contents of our `git-log` fixture
  var that = this;
  fixtureDir.mkdir({
    folderName: 'git-log',
    copyFrom: __dirname + '/test-files/git-log' // Folder with `.git` activity
  }, function (err, dir) {
    // Save the directory for cleanup and callback
    that.dir = dir;
    done();
  });
});
before(function (done) {
  // Run `git log` in our directory
  exec('git log', {cwd: this.dir.path}, function (err, stdout, stderr) {
    // Save our stdout and callback
    this.stdout = stdout;
    done(err);
  });
});<commit_msg>Added more information to example<commit_after># fixture-dir [![Build status](https://travis-ci.org/twolfson/fixture-dir.png?branch=master)](https://travis-ci.org/twolfson/fixture-dir)

Create/copy directory to temporary directory

This was built for quickly setting up/tearing down directories that originate from tests but should not contaminate the repo. Previous to this repo's creation, I have used this pattern in [foundry-release-git][] and [sexy-bash-prompt][].

[foundry-release-git]: https://github.com/twolfson/foundry-release-git/blob/1.0.1/test/utils/fixtures.js
[sexy-bash-prompt]: https://github.com/twolfson/sexy-bash-prompt/blob/0.21.0/test/prompt_test.sh#L8-L19

A mocha flavor, [mocha-fixture-dir][], is available for automatic directory cleanup.

[mocha-fixture-dir]: https://github.com/twolfson/mocha-fixture-dir

## Getting Started
Install the module with: `npm install fixture-dir`

```javascript
// Generate a tmp namespace for our tests
var exec = require('child_process').exec;
var FixtureDir = require('fixture-dir');
var fixtureDir = new FixtureDir('my-node-module-tests');

// Inside of our tests, copy over folder contents and interact with them
before(function () {
  // Create a `git-log` folder with the contents of our `git-log` fixture
  var that = this;
  fixtureDir.mkdir({
    folderName: 'git-log',
    copyFrom: __dirname + '/test-files/git-log' // Folder with `.git` activity
  }, function (err, dir) {
    // Save the directory for cleanup and callback
    that.dir = dir;
    done();
  });
});
before(function (done) {
  // Run `git log` in our directory (/tmp/my-node-module-tests/git-log)
  exec('git log', {cwd: this.dir.path}, function (err, stdout, stderr) {
    // Save our stdout and callback
    this.stdout = stdout;
    done(err);
  });
});
{'fraction_non_alphanumeric': 0.1413597733711048, 'fraction_numerical': 0.0056657223796034, 'mean_word_length': 4.065997130559541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5574330', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1127, 'n_words': 323}