Skip to content

Commit

Permalink
tests: lib/tessel/deployment/javascript.js coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 20, 2017
1 parent 4f0e3f8 commit e312501
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 112 deletions.
50 changes: 32 additions & 18 deletions lib/tessel/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ exportables.tarBundle = function(options) {
// Mark binary modules that should be ignored
binaryModulesUsed.forEach(details => {
ignoreRules.forEach(rule => {
if (minimatch(details.modulePath, rule, matchOptions)) {
/* istanbul ignore else */
if (exportables.minimatch(details.modulePath, rule, matchOptions)) {
details.ignored = true;
details.resolved = false;
}
Expand Down Expand Up @@ -604,21 +605,20 @@ exportables.tarBundle = function(options) {
type: 'Directory',
});

fstream
.on('entry', (entry) => {
entry.root = {
path: entry.path
};
})
.pipe(packer)
.on('data', (chunk) => {
fstream.on('entry', entry => {
entry.root = {
path: entry.path
};
});

fstream.on('error', error => reject(error));

fstream.pipe(packer)
.on('data', chunk => {
buffers.push(chunk);
})
.on('error', (data) => {
reject(data);
})
.on('end', () => {
fs.remove(tempBundleDir, (error) => {
fs.remove(tempBundleDir, error => {
if (error) {
reject(error);
} else {
Expand Down Expand Up @@ -677,20 +677,19 @@ exportables.tarBundle = function(options) {
// This ensures that the remote root directory
// is the same level as the directory containing
// our program entry-point files.
fstream.on('entry', (entry) => {
fstream.on('entry', entry => {
entry.root = {
path: entry.path
};
});

fstream.on('error', error => reject(error));

// Send the ignore-filtered file stream into the tar packer
fstream.pipe(packer)
.on('data', (chunk) => {
.on('data', chunk => {
buffers.push(chunk);
})
.on('error', (data) => {
reject(data);
})
.on('end', () => {
resolve(Buffer.concat(buffers));
});
Expand All @@ -714,6 +713,21 @@ exportables.project = function(options) {
return new Project(options);
};

/**
* Minimatch comparison
* Language: js
*
* @param {String} modulePath Path to module root.
* @param {String} rule Rule to compare with
* @param {Object} matchOptions Matching options (see minimatch docs)
*/
exportables.minimatch = function(modulePath, rule, matchOptions) {
// To make these operations testable, we must wrap them
// in our own exported `exportables`.

return minimatch(modulePath, rule, matchOptions);
};

/**
* Compress JS files
* Language: js
Expand Down
1 change: 1 addition & 0 deletions test/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"log": true,
"Menu": true,
"mdns": true,
"minimatch": true,
"mkdirp": true,
"npm": true,
"NodeRSA": true,
Expand Down
2 changes: 1 addition & 1 deletion test/common/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ global.fstream = require('fstream');
global.Ignore = require('fstream-ignore');
global.inquirer = require('inquirer');
global.mdns = require('mdns-js');
global.minimatch = require('minimatch');
global.mkdirp = require('mkdirp');
global.npm = require('npm');
global.npmlog = require('npmlog');
Expand All @@ -44,7 +45,6 @@ global.tags = require('common-tags');
global.tar = require('tar');
global.uglify = require('uglify-es');


// Internal
// ./lib/tessel/*
global.Tessel = require('../../lib/tessel/tessel');
Expand Down

0 comments on commit e312501

Please sign in to comment.