This repository has been archived by the owner on Dec 12, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
763021b
commit da26738
Showing
14 changed files
with
168 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import test from 'ava' | ||
import is from '../util/is' | ||
|
||
test('is string', t => { | ||
t.true(is.string('')) | ||
t.false(is.string(123)) | ||
}) | ||
|
||
test('is array', t => { | ||
t.true(is.array([])) | ||
t.false(is.array('')) | ||
}) | ||
|
||
test('is object', t => { | ||
t.true(is.object({})) | ||
t.false(is.object('')) | ||
}) | ||
|
||
test('is boolean', t => { | ||
t.true(is.boolean(true)) | ||
t.true(is.boolean(false)) | ||
t.false(is.boolean({})) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import test from 'ava' | ||
import logger from '../util/logger' | ||
|
||
test('logger warn', t => { | ||
t.notThrows(function () { | ||
logger.warn('ok') | ||
}) | ||
}) | ||
|
||
test('logger log', t => { | ||
t.notThrows(function () { | ||
logger.log('ok') | ||
}) | ||
}) | ||
|
||
test('logger success', t => { | ||
t.notThrows(function () { | ||
logger.success('ok') | ||
}) | ||
}) | ||
|
||
test('logger error', t => { | ||
t.notThrows(function () { | ||
logger.error('ok') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var pluginExists = require('./check').pluginExists | ||
var logger = require('./logger') | ||
var isArray = require('./is').array | ||
var isString = require('./is').string | ||
var exec = require('./exec') | ||
|
||
var installExtend = function (name) { | ||
logger.warn('依赖包不存在,自动下载依赖包: ' + name) | ||
exec('cooking', ['import', name, '-p'], { | ||
stdio: 'inherit' | ||
}) | ||
} | ||
|
||
module.exports = function (pkg) { | ||
if (!pkg) { | ||
return | ||
} | ||
|
||
if (!isString || !isArray) { | ||
logger.fatal('use 字段只接受数组和字符串类型') | ||
} | ||
|
||
if (isString(pkg)) { | ||
pkg = [pkg] | ||
} | ||
|
||
pkg.forEach(function (name) { | ||
if (!pluginExists('cooking-pkg-' + name)) { | ||
installExtend(name) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters