Skip to content

Commit

Permalink
Remove dependency on homedir package (hyperledger-archives#3888)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and Simon Stone committed Apr 20, 2018
1 parent 73f3810 commit be26624
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 27 deletions.
1 change: 0 additions & 1 deletion NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ The Program includes some or all of the following that IBM obtained under the MI
- Thenify-all - Copyright (c) 2014 Jonathan Ong [email protected]
- Thenify - Copyright (c) 2014-2016 Jonathan Ong [email protected] and contributors
- node-fs-extra - Copyright (c) 2011-2017 JP Richardson
- node-homedir - Copyright (c) 2014 Wil Moore III
- npm-paths - Copyright (c) 2015-2016, Jon Schlinkert.
- Prettyjson - Copyright (c) 2011 Rafael de Oleza <[email protected]>
- node-sanitize-filename - Copyright (C) 2004 Sam Hocevar \<[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions packages/composer-cli/gen/transactiontemplate
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

'use strict';
const fs = require('fs');
const os = require('os');
const Client = require('composer-client');
const Admin = require('composer-admin');
const Common = require('composer-common');
const BusinessNetworkDefinition = Admin.BusinessNetworkDefinition;
const BusinessNetworkConnection = Client.BusinessNetworkConnection;
const AdminConnection = Admin.AdminConnection;
const homedir = require('homedir');

const PROFILE_ROOT = homedir() + '/.composer-connection-profiles/';
const PROFILE_ROOT = os.homedir() + '/.composer-connection-profiles/';
const CONNECTION_FILE = 'connection.json';

const CREDENTIALS_ROOT = homedir() + '/.composer-credentials';
const CREDENTIALS_ROOT = os.homedir() + '/.composer-credentials';
const DEFAULT_PROFILE_NAME = 'defaultProfile';

require('chai').should();
Expand Down
1 change: 0 additions & 1 deletion packages/composer-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"composer-report": "0.19.2",
"composer-wallet-filesystem": "0.19.2",
"composer-wallet-inmemory": "0.19.2",
"homedir": "0.6.0",
"js-yaml": "3.10.0",
"mkdirp": "0.5.1",
"moment": "2.19.3",
Expand Down
11 changes: 3 additions & 8 deletions packages/composer-common/lib/filewallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
'use strict';

const fs = require('fs');
const homedir = require('homedir');
const Logger = require('./log/logger');
const mkdirp = require('mkdirp');
const path = require('path');
const thenify = require('thenify');
const thenifyAll = require('thenify-all');
const composerUtil = require('./util');
const Wallet = require('./wallet');

const LOG = Logger.getLog('FileWallet');
Expand All @@ -39,7 +39,7 @@ class FileWallet extends Wallet {
* @return {string} The current home directory.
*/
static getHomeDirectory() {
return homedir();
return composerUtil.homeDirectory();
}

/**
Expand All @@ -58,12 +58,7 @@ class FileWallet extends Wallet {
options = options || {};
this.directory = options.directory;
if (!this.directory) {
let h = FileWallet.getHomeDirectory();
if (h) {
this.directory = path.resolve(h, '.composer-credentials');
} else {
this.directory = path.resolve('/', '.composer-credentials');
}
this.directory = path.resolve(FileWallet.getHomeDirectory(), '.composer-credentials');
LOG.debug(method, 'Generated directory', this.directory);
}

Expand Down
1 change: 0 additions & 1 deletion packages/composer-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"esprima": "3.1.2",
"fs-extra": "1.0.0",
"fs-promise": "1.0.0",
"homedir": "0.6.0",
"js-yaml": "3.10.0",
"jsrsasign": "8.0.3",
"jszip": "3.1.3",
Expand Down
10 changes: 2 additions & 8 deletions packages/composer-common/test/filewallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const BrowserFS = require('browserfs/dist/node/index');
const bfs_fs = BrowserFS.BFSRequire('fs');
const FileWallet = require('../lib/filewallet');
const fs = require('fs');
const homedir = require('homedir');
const mkdirp = require('mkdirp');
const os = require('os');
const path = require('path');

const chai = require('chai');
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('FileWallet', () => {
describe('#getHomeDirectory', () => {

it('should return the home directory', () => {
FileWallet.getHomeDirectory().should.equal(homedir());
FileWallet.getHomeDirectory().should.equal(os.homedir());
});

});
Expand All @@ -76,12 +76,6 @@ describe('FileWallet', () => {
fileWallet.directory.should.equal(path.resolve('/home/doge1', '.composer-credentials'));
});

it('should use the root directory by default if no home directory available', () => {
sandbox.stub(FileWallet, 'getHomeDirectory').returns(null);
fileWallet = new FileWallet();
fileWallet.directory.should.equal(path.resolve('/', '.composer-credentials'));
});

it('should use the specified directory', () => {
fileWallet = new FileWallet({
directory: '/var/composer'
Expand Down
1 change: 0 additions & 1 deletion packages/composer-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
"file-loader": "0.10.0",
"file-saver": "1.3.3",
"gh-pages": "0.12.0",
"homedir": "0.6.0",
"html-webpack-plugin": "2.25.0",
"ie-shim": "0.1.0",
"imports-loader": "0.7.0",
Expand Down
1 change: 0 additions & 1 deletion packages/composer-tests-functional/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"dockerode": "2.5.1",
"eslint": "3.17.1",
"express": "4.15.2",
"homedir": "0.6.0",
"karma": "1.3.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/composer-wallet-filesystem/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
const util=require('util');
const rimraf = util.promisify(require('rimraf'));
const mkdirp = require('mkdirp');
const homedir = require('homedir');
const os = require('os');
const path= require('path');

module.exports.getStore = require('../index.js').getStore;
Expand All @@ -32,10 +32,10 @@ module.exports.correctConfigs=[
module.exports.clean=async ()=>{
await rimraf('/tmp/filestemwallet');
mkdirp.sync('/tmp/filestemwallet');
await rimraf(path.resolve(homedir(),'.composer'));
await rimraf(path.resolve(os.homedir(),'.composer'));
};

module.exports.messages={
GET_NON_EXISTANT:/no such file or directory/,
GET_INVALID_NAME:/Name must be specified/
};
};

0 comments on commit be26624

Please sign in to comment.