New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imdone-core

Package Overview
Dependencies
Maintainers
1
Versions
476
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imdone-core - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

test/test-plugin.js

15

lib/project.js

@@ -160,3 +160,3 @@ var _ = require('lodash'),

// DONE:10 Add file.update and file.delete listener for repos and emit project.modified
// DONE:20 Add file.update and file.delete listener for repos and emit project.modified
/**

@@ -169,3 +169,3 @@ * Description

this.fileUpdateListener = function(file) {
// DONE:40 fix emit modified by saving these up and emitting only if a backlog exists
// DONE:50 fix emit modified by saving these up and emitting only if a backlog exists
self.emit('file.update', {project:self.getName(), file:file});

@@ -242,4 +242,4 @@ self.queueModified({mod:'file.update', file:file.getPath()});

// DONE:80 Use async file operations
// DONE:20 Only save config if there is more than one repo
// DONE:90 Use async file operations
// DONE:30 Only save config if there is more than one repo
/**

@@ -254,2 +254,3 @@ * Description

if (cb === undefined) cb = _.noop;
// Only store config if there is more than one Repo
if (this.getRepos().length === 1) return cb();

@@ -342,3 +343,3 @@ var dir = this.getConfigDir();

// DONE:50 Implement addRepo and removeRepo
// DONE:60 Implement addRepo and removeRepo
/**

@@ -622,3 +623,3 @@ * Description

// DONE:70 Test moveTasks
// DONE:80 Test moveTasks
/**

@@ -817,3 +818,3 @@ * Description

// DONE:30 getFilesTree should return a nested list of files
// DONE:40 getFilesTree should return a nested list of files
/**

@@ -820,0 +821,0 @@ * Description

@@ -56,4 +56,6 @@ var _ = require('lodash'),

this.config = new Config(this.config);
this.plugins = {};
_.defaults(this.config, _.cloneDeep(DEFAULT_CONFIG));
this.initPlugins();
this.createListeners();

@@ -77,3 +79,5 @@ }

this.readFiles(function(err, files) {
if (self.config.watcher) self.initWatcher();
if (self.config.watcher) { self.initWatcher(); }
self.emit('initialized', {ok:true});
log('initialized');
cb(err,files);

@@ -97,2 +101,74 @@ });

/**
* Initializes all plugins
* @method initPlugins
* @return
*/
Repository.prototype.initPlugins = function() {
var self = this;
_.each(this.config.plugins, function(config, name) {
self.initPlugin(name, config);
});
};
/**
* Initializes a single plugin
* @method initPlugin
* @return
*/
Repository.prototype.initPlugin = function(name, config) {
var pluginPath;
// First try to resolve the plugin in the paths node_modules
try {
var _path = path.join(this.path, 'node_modules', name);
log('Looking for plugin:%s', _path);
require.resolve(_path);
pluginPath = _path;
} catch (e) {}
// Now check the users home node_modules
if (!pluginPath) {
try {
var _path = path.join(tools.userHome(), 'node_modules', name);
log('Looking for plugin:%s', _path);
require.resolve(_path);
pluginPath = _path;
} catch (e) {}
}
// Now just try to load the module by name
if (!pluginPath) {
try {
log('Looking for plugin:%s', name);
require.resolve(name);
pluginPath = name;
} catch (e) {}
}
if (pluginPath) {
log('Found plugin:%s', pluginPath);
this.plugins[pluginPath] = require(pluginPath)(config, this);
}
};
/**
* Get a plugin by package name
* @method plugin
* @return The named plugin object or undefined
*/
Repository.prototype.plugin = function(name) {
return this.plugins[name];
};
/**
* Add a plugin
* @method plugin
* @return this for chaining
*/
Repository.prototype.addPlugin = function(name, config) {
this.initPlugin(name, config);
if (this.config.plugins === undefined) this.config.plugins = {};
this.config.plugins[name] = config;
};
/**
* Description

@@ -121,6 +197,6 @@ * @method getId

if (!self.listExists(task.list)) {
self.emit('list.found', list);
var list = _.pick(new List(task.getList()), "name", "hidden");
list = new List(list.name, list.hidden);
self.addList(list);
self.emit('list.found', list);
self.saveConfig();

@@ -254,3 +330,3 @@ }

// DONE:0 Make sure lists are not saved on load in alphabetical order
// DONE:10 Make sure lists are not saved on load in alphabetical order
/**

@@ -346,6 +422,11 @@ * Save the config file

if (this.shouldExclude(file)) return false;
var stat = fs.lstatSync(this.getFullPath(file));
if ( /\.\.(\/|\\)/.test(file) ||
(!includeDirs && !stat.isFile()) ||
(stat.isFile() && isBinaryFileSync(this.getFullPath(file))) ) return false;
var stat = false;
try {
stat = fs.lstatSync(this.getFullPath(file));
if ( /\.\.(\/|\\)/.test(file) ||
(!includeDirs && !stat.isFile()) ||
(stat.isFile() && isBinaryFileSync(this.getFullPath(file))) ) stat = false;
} catch (e) {
stat = false;
}

@@ -450,3 +531,2 @@ return stat;

Repository.prototype.extractTasks = function(file) {
var self = this;
file.on('task.found', this.taskFoundListener);

@@ -710,3 +790,3 @@ file.extractTasks();

// DONE:60 Test renameList
// DONE:70 Test renameList
/**

@@ -713,0 +793,0 @@ * Description

{
"name": "imdone-core",
"version": "0.0.6",
"version": "0.0.7",
"description": "imdone-core",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,1 +17,13 @@ imdone-core

- Config
2. [Add plugin capability](#DONE:0)
- Config
```js
{
...
plugins: {
"npm package name": {plugin specific config}
}
}
```
- Install with npm install

@@ -10,2 +10,3 @@ var should = require('should'),

wrench = require('wrench'),
log = require('debug')('imdone-core:repository-spec');
async = require('async');

@@ -181,2 +182,38 @@

});
describe('plugin', function() {
var tmpDir = path.join(process.cwd(), "tmp"),
tmpReposDir = path.join(tmpDir, "repos"),
repoSrc = path.join(process.cwd(), "test", "repos"),
repo1Dir = path.join(tmpReposDir, "repo1"),
repo2Dir = path.join(tmpReposDir, "repo2"),
repo1,
repo2;
beforeEach(function() {
wrench.mkdirSyncRecursive(tmpDir);
wrench.copyDirSyncRecursive(repoSrc, tmpReposDir, {forceDelete: true});
repo1 = new Repository(repo1Dir, {watcher:false});
repo2 = new Repository(repo2Dir, {watcher:false});
});
afterEach(function() {
repo1.destroy();
repo2.destroy();
wrench.rmdirSyncRecursive(tmpDir, true);
});
it('should return the named plugin object', function(done) {
var name = path.join(process.cwd(), "test", "test-plugin");
repo1.addPlugin(name, {foo:"bar"});
repo1.saveConfig(function(err) {
repo1.init(function(err) {
var plugin = repo1.plugin(name);
expect(plugin.config).to.be(repo1.config.plugins[name]);
expect(plugin.repo).to.be(repo1);
done();
});
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc