From 76c8896f4ecf104d0df158582232e302fe744719 Mon Sep 17 00:00:00 2001 From: sanemat Date: Tue, 21 Jul 2015 11:43:13 +0900 Subject: [PATCH] feat(scoped): implement scoped package --- index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 367ec57..161039e 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,14 @@ 'use strict'; -module.exports = function (str, opts) { - if (typeof str !== 'string') { - throw new TypeError('Expected a string'); - } - opts = opts || {}; +var isPackage = require('is-package'); +var npa = require('npm-package-arg'); - return str + ' & ' + (opts.postfix || 'rainbows'); +module.exports = function (name) { + var bool; + try { + bool = isPackage(name) && (npa(name)['scope']); + } catch (e) { + bool = false; + } + return bool; };