Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge github.com:rakistner/dawson-cli into fix-163
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Lusenti committed Mar 30, 2017
2 parents 01b479c + 807cc48 commit b41b5bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/config.js
Expand Up @@ -2,7 +2,17 @@
// this will compile on-the-fly the `api.js` required below
// by `require(PROJECT_ROOT + '/api');`

export const BABEL_CONFIG = {
import path from 'path';
// Support for `babel` property in project package.json to extend base babel config
// to add plugins and more presets, etc. React, JSX Transform, Syntax support
const babelRequiredPkgJson = require(path.join(process.cwd(), 'package.json'));
// check if key is package.json
let hasBabelConfigInPkgJson = ('babel' in babelRequiredPkgJson);
// if key, use that babel config, add babelrc = false
// else, use default
export const BABEL_CONFIG = hasBabelConfigInPkgJson ? Object.assign(babelRequiredPkgJson['babel'], {
babelrc: false
}) : {
// also used in libs/createBundle.js
presets: ['dawson'],
babelrc: false
Expand Down
2 changes: 2 additions & 0 deletions src/libs/language-javascript-latest/compile.js
Expand Up @@ -14,6 +14,8 @@ const makeBabelArgs = (ignore = []) => ([
(BABEL_CONFIG.babelrc === false) ? '--no-babelrc' : null,
'--presets',
BABEL_CONFIG.presets.map(p => Array.isArray(p) ? p[0] : p).join(','), // only preset names, without config
'--plugins',
BABEL_CONFIG.plugins.map(p => Array.isArray(p) ? p[0] : p).join(','), // only plugin names, without config
'--copy-files'
].filter(Boolean));

Expand Down
7 changes: 5 additions & 2 deletions src/libs/language-javascript-latest/installDeps.js
@@ -1,12 +1,15 @@
import execa from 'execa';
import { oneLine } from 'common-tags';
import { BABEL_CONFIG } from '../../config';

export default function install ({ skipChmod }) {
return execa.shell(
oneLine`
cd .dawson-dist &&
NODE_ENV=production npm install --production babel-cli babel-polyfill babel-preset-env
babel-plugin-transform-object-rest-spread &&
NODE_ENV=production npm install --production babel-cli babel-polyfill
babel-preset-env babel-plugin-transform-object-rest-spread
${('presets' in BABEL_CONFIG) && Array.isArray(BABEL_CONFIG.presets) ? BABEL_CONFIG.presets.map(p => 'babel-preset-' + (Array.isArray(p) ? p[0] : p)).join(' ') : null}
${('plugins' in BABEL_CONFIG) && Array.isArray(BABEL_CONFIG.plugins) ? BABEL_CONFIG.plugins.map(p => 'babel-plugin-' + (Array.isArray(p) ? p[0] : p)).join(' ') : null} &&
NODE_ENV=production npm install --production
${skipChmod ? '' : '&& chmod -Rf a+rX .'}`
);
Expand Down

0 comments on commit b41b5bb

Please sign in to comment.