Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new changes #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: "Use npm modules with your Meteor App",
version: "1.5.0",
version: "1.5.1",
git: "https://github.com/meteorhacks/npm.git",
name: "meteorhacks:npm"
});
Expand Down
44 changes: 22 additions & 22 deletions plugin/init_npm.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var path = Npm.require('path');
var fs = Npm.require('fs');
var mkdirp = Npm.require('mkdirp');
var echo = Npm.require('node-echo');
var beautify = Npm.require('js-beautify');
var path = require('path');
var fs = require('fs');
var mkdirp = require('mkdirp');
var echo = require('node-echo');
var beautify = require('js-beautify');

var npmContainerDir = path.resolve('./packages/npm-container');
var packagesJsonPath = path.resolve('./packages.json');
var packageJsPath = path.resolve(npmContainerDir, 'package.js');
var indexJsPath = path.resolve(npmContainerDir, 'index.js');

if(canProceed() && !fs.existsSync(packagesJsonPath)) {
if (canProceed() && !fs.existsSync(packagesJsonPath)) {
console.log('\n');
console.log("-> creating `packages.json` for the first time.");
console.log("-> add your npm modules to `packages.json`");
Expand All @@ -18,7 +18,7 @@ if(canProceed() && !fs.existsSync(packagesJsonPath)) {
fs.writeFileSync(packagesJsonPath, '{\n \n}');
}

if(canProceed() && !fs.existsSync(npmContainerDir)) {
if (canProceed() && !fs.existsSync(npmContainerDir)) {
console.log("=> Creating container package for npm modules");

// create new npm container directory
Expand All @@ -42,10 +42,10 @@ if(canProceed() && !fs.existsSync(npmContainerDir)) {

// check whether is this `meteor test-packages` or not
function canProceed() {
var unAcceptableCommands = {'test-packages': 1, 'publish': 1};
if(process.argv.length > 2) {
var unAcceptableCommands = { 'test-packages': 1, 'publish': 1 };
if (process.argv.length > 2) {
var command = process.argv[2];
if(unAcceptableCommands[command]) {
if (unAcceptableCommands[command]) {
return false;
}
}
Expand All @@ -57,9 +57,9 @@ function canProceed() {
function getContent(func) {
var lines = func.toString().split('\n');
// Drop the function declaration and closing bracket
var onlyBody = lines.slice(1, lines.length -1);
var onlyBody = lines.slice(1, lines.length - 1);
// Drop line number comments generated by Meteor, trim whitespace, make string
onlyBody = _.map(onlyBody, function(line) {
onlyBody = _.map(onlyBody, function (line) {
return line.slice(0, line.lastIndexOf("//")).trim();
}).join('\n');
// Make it look normal
Expand All @@ -69,20 +69,20 @@ function getContent(func) {
// Following function has been defined to just get the content inside them
// They are not executables
function _indexJsContent() {
Meteor.npmRequire = function(moduleName) {
Meteor.npmRequire = function (moduleName) {
var module = Npm.require(moduleName);
return module;
};

Meteor.require = function(moduleName) {
Meteor.require = function (moduleName) {
console.warn('Meteor.require is deprecated. Please use Meteor.npmRequire instead!');
return Meteor.npmRequire(moduleName);
};
}

function _packageJsContent () {
var path = Npm.require('path');
var fs = Npm.require('fs');
function _packageJsContent() {
var path = require('path');
var fs = require('fs');

Package.describe({
summary: 'Contains all your npm dependencies',
Expand All @@ -94,19 +94,19 @@ function _packageJsContent () {
try {
var fileContent = fs.readFileSync(packagesJsonFile);
var packages = JSON.parse(fileContent.toString());
Npm.depends(packages);
} catch(ex) {
depends(packages);
} catch (ex) {
console.error('ERROR: packages.json parsing error [ ' + ex.message + ' ]');
}

// Adding the app's packages.json as a used file for this package will get
// Meteor to watch it and reload this package when it changes
Package.onUse(function(api) {
Package.onUse(function (api) {
api.addFiles('index.js', 'server');
if(api.addAssets) {
if (api.addAssets) {
api.addAssets('../../packages.json', 'server');
} else {
api.addFiles('../../packages.json', 'server', {isAsset: true});
api.addFiles('../../packages.json', 'server', { isAsset: true });
}
});
}