From b1adf272d0576d8b7a43182b037b1670d247f9f2 Mon Sep 17 00:00:00 2001 From: Hackzzila Date: Wed, 10 May 2017 08:28:11 -0500 Subject: [PATCH] 0.10.1 --- package.json | 2 +- src/cli/diamond-publish.js | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 225b8ee..8d70f39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diamondpkg", - "version": "0.10.0", + "version": "0.10.1", "description": "Dependency management built for Sass, Less, and CSS.", "preferGlobal": true, "engines": { diff --git a/src/cli/diamond-publish.js b/src/cli/diamond-publish.js index 0c43415..aa65c27 100644 --- a/src/cli/diamond-publish.js +++ b/src/cli/diamond-publish.js @@ -30,24 +30,37 @@ exports.handler = (args) => { process.exit(1); } - let packageJson; + let info = {}; try { - packageJson = JSON.parse(fs.readFileSync('./diamond.json')); + info = JSON.parse(fs.readFileSync('./diamond.json')); } catch (err) { - log.error('no diamond.json found'); - process.exit(1); + let packageJson; + try { + packageJson = JSON.parse(fs.readFileSync('./package.json')); + } catch (e) { + log.error('no \'diamond.json\' or \'package.json\' found'); + process.exit(1); + } + + info.name = packageJson.name; + info.version = packageJson.version; + info.description = packageJson.description; + info.main = packageJson.diamond || packageJson.sass || packageJson.less || + (packageJson.main && !packageJson.main.endsWith('.js') ? packageJson.main : packageJson.style); + + log.warn('using \'package.json\'', 'all fields may not be supported'); } - if (!packageJson.name) { + if (!info.name) { log.error('no \'name\' field'); process.exit(1); - } else if (!packageJson.version) { + } else if (!info.version) { log.error('no \'version\' field'); process.exit(1); - } else if (!packageJson.description) { + } else if (!info.description) { log.error('no \'description\' field'); process.exit(1); - } else if (!packageJson.main) { + } else if (!info.main) { log.warn('no \'main\' field'); } @@ -80,9 +93,9 @@ exports.handler = (args) => { }); stream.on('end', () => { - superagent.post(`${config.registry}/package/${packageJson.name}`) + superagent.post(`${config.registry}/package/${info.name}`) .auth(auth.username, auth.password) - .field('package', JSON.stringify(packageJson)) + .field('package', JSON.stringify(info)) .field('readme', readme || '') .attach('dist', file, 'dist.tar.gz') .then((res) => {