Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

egg-utils

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-utils - npm Package Compare versions

Comparing version
1.1.0
to
2.0.0
+50
lib/framework.js
'use strict';
const path = require('path');
const assert = require('assert');
const fs = require('fs');
module.exports = { getFrameworkPath };
/**
* Find the framework directory, lookup order
* - specify framework path
* - get framework name from
* - use egg by default
* @param {Object} options - options
* @param {String} options.baseDir - the current directory of application
* @param {String} [options.framework] - the directory of framework
* @return {String} frameworkPath
*/
function getFrameworkPath({ framework, baseDir }) {
const pkgPath = path.join(baseDir, 'package.json');
assert(fs.existsSync(pkgPath), `${pkgPath} should exist`);
const moduleDir = path.join(baseDir, 'node_modules');
const pkg = require(pkgPath);
// 1. pass framework or customEgg
if (framework) {
// 1.1 framework is an absolute path
// framework: path.join(baseDir, 'node_modules/${frameworkName}')
if (path.isAbsolute(framework)) return assertAndReturn(framework);
// 1.2 framework is a npm package that required by application
// framework: 'frameworkName'
return assertAndReturn(path.join(moduleDir, framework));
}
// 2. framework is not specified
// 2.1 use framework name from pkg.egg.framework
if (pkg.egg && pkg.egg.framework) {
return assertAndReturn(path.join(moduleDir, pkg.egg.framework));
}
// 2.2 use egg by default
return assertAndReturn(path.join(moduleDir, 'egg'));
}
function assertAndReturn(frameworkPath) {
assert(fs.existsSync(frameworkPath), `${frameworkPath} should exist`);
return frameworkPath;
}
+6
-0
2.0.0 / 2017-03-01
==================
* feat: move getFrameworkPath from egg-cluster (#2)
* deps: only support node >= 6.0.0
1.1.0 / 2017-01-13

@@ -3,0 +9,0 @@ ==================

+10
-3

@@ -6,2 +6,8 @@ 'use strict';

[
require('./lib/framework'),
{ getFrameworkOrEggPath },
]
.forEach(obj => Object.assign(exports, obj));
/**

@@ -14,5 +20,6 @@ * Try to get framework dir path

* @return {String} framework or egg dir path
* @deprecated
*/
exports.getFrameworkOrEggPath = (cwd, eggNames) => {
eggNames = eggNames || ['egg'];
function getFrameworkOrEggPath(cwd, eggNames) {
eggNames = eggNames || [ 'egg' ];
const moduleDir = path.join(cwd, 'node_modules');

@@ -60,2 +67,2 @@ if (!fs.existsSync(moduleDir)) {

return '';
};
}

@@ -1,4 +0,4 @@

The MIT License (MIT)
MIT License
Copyright (c) Alibaba Group Holding Limited and other contributors.
Copyright (c) 2017 Alibaba Group Holding Limited and other contributors.

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "egg-utils",
"version": "1.1.0",
"version": "2.0.0",
"description": "Utils for all egg projects",
"main": "index.js",
"files": [
"index.js"
"index.js",
"lib"
],
"scripts": {
"test": "NODE_ENV=test ava",
"cov": "NODE_ENV=test nyc ava && nyc report --reporter=json --reporter=lcov",
"lint": "eslint *.js test --fix",
"lint": "eslint .",
"test": "npm run lint && ypkgfiles && egg-bin test",
"cov": "egg-bin cov",
"ci": "npm run lint && npm run cov",
"autod": "autod -w --prefix='^'"
"autod": "autod"
},

@@ -28,8 +29,8 @@ "keywords": [

"devDependencies": {
"autod": "^2.6.1",
"ava": "^0.15.2",
"egg-ci": "^1.0.2",
"eslint": "^2.13.0",
"eslint-config-egg": "^2.0.0",
"nyc": "^6.6.1"
"autod": "^2.7.1",
"egg-bin": "^2.2.3",
"egg-ci": "^1.3.0",
"eslint": "^3.16.1",
"eslint-config-egg": "^3.2.0",
"ypkgfiles": "^1.2.0"
},

@@ -39,10 +40,6 @@ "engine": {

},
"ava": {
"files": [
"test/**/*.test.js"
]
},
"ci": {
"version": "6, 7"
"version": "6, 7",
"license": true
}
}