Navigation Menu

Skip to content

Commit

Permalink
Error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguo committed May 8, 2018
1 parent 79dd6b4 commit 1b738c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions bin/tpl.js
Expand Up @@ -7,11 +7,11 @@ var gkaNodeModulesDir = path.join(__dirname, '..', 'node_modules');

gkaNodeModulesDir = fs.existsSync(gkaNodeModulesDir)? gkaNodeModulesDir: path.join(__dirname, '..', '..');

function getNodePath (argument) {
var ps = spawn.sync('npm', ['root', '-g'], {}),
npmRoot = (ps && ps.stdout) ? ps.stdout.toString().replace(/[\n\t\r]/g,"") : "";
return npmRoot;
}
// function getNodePath (argument) {
// var ps = spawn.sync('npm', ['root', '-g'], {}),
// npmRoot = (ps && ps.stdout) ? ps.stdout.toString().replace(/[\n\t\r]/g,"") : "";
// return npmRoot;
// }

function getGlobalTpls() {
var npmRoot = process.env.NODE_PATH,
Expand All @@ -20,7 +20,8 @@ function getGlobalTpls() {
try {
tpls = fs.readdirSync(npmRoot); // NODE_PATH 无设置或设置多个值,则使用 catch 中方案
} catch (e) {
npmRoot = getNodePath();
// npmRoot = getNodePath();
npmRoot = require('global-modules');
try {
tpls = fs.readdirSync(npmRoot);
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions lib/templates/CssTemplatePlugin.js
Expand Up @@ -92,7 +92,7 @@ function effectSubFolderSync(run, dataArr, opts) {
}
}

function checkRatio(frames, ratio) {
function checkRatio(frames, ratio = 1) {
return frames.map(item => {
return {
src: item.src,
Expand All @@ -112,7 +112,7 @@ function checkRatio(frames, ratio) {
})
}

function toFrameCSSObject(frame, ratio) {
function toFrameCSSObject(frame, ratio = 1) {
let {
width,
height,
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/SvgTemplatePlugin.js
Expand Up @@ -48,7 +48,7 @@ module.exports = class SvgTemplatePlugin {
}
}

function toFrameCSSObject(frame, ratio) {
function toFrameCSSObject(frame, ratio = 1) {
let {
width,
height,
Expand Down

0 comments on commit 1b738c9

Please sign in to comment.