This repository has been archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
deepsweet
committed
Dec 16, 2015
1 parent
ce1b6cc
commit 940045e
Showing
6 changed files
with
99 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [ "es2015", "stage-0" ] | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
node_modules/ | ||
tmp/ | ||
build/ | ||
coverage/ | ||
tmp/ | ||
node_modules/ | ||
*.sublime-* | ||
*.log | ||
.DS_Store |
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 |
---|---|---|
|
@@ -10,12 +10,27 @@ | |
"Denis Koltsov <[email protected]> (https://github.com/mistadikay)" | ||
], | ||
"files": [ | ||
"components/", | ||
"build/", | ||
"LICENSE" | ||
], | ||
"peerDependencies": { | ||
"@yummies/yummies": ">=0.13.0 <2.0.0", | ||
"@yummies/dom": ">=0.2.0 <2.0.0" | ||
"@yummies/yummies": ">=0.13.0 <2.0.0" | ||
}, | ||
"devDependencies": { | ||
"start": "1.1.x", | ||
"del": "2.2.x", | ||
"node-dir": "0.1.x", | ||
"mkdirp": "0.5.x", | ||
"less": "2.5.x", | ||
|
||
"babel-core": "6.3.x", | ||
"babel-cli": "6.3.x", | ||
"babel-preset-es2015": "6.3.x", | ||
"babel-preset-stage-0": "6.3.x" | ||
}, | ||
"scripts": { | ||
"task": "babel-node node_modules/.bin/start tasks/", | ||
"build": "npm run task build" | ||
}, | ||
"engines": { | ||
"node": ">=0.12.0", | ||
|
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,64 @@ | ||
const inFileName = 'styles.less'; | ||
const outFileName = 'styles.css'; | ||
const lessOptions = { | ||
compress: false, | ||
relativeUrls: true | ||
}; | ||
|
||
export function lessBuild() { | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const recursiveReadDir = require('node-dir'); | ||
const mkdirp = require('mkdirp'); | ||
const less = require('less'); | ||
|
||
const inRootDir = path.resolve('components/'); | ||
const outRootDir = path.resolve('build/'); | ||
|
||
return new Promise((rootResolve, rootReject) => { | ||
recursiveReadDir.paths(inRootDir, (readDirErr, readDirResult) => { | ||
if (readDirErr) { | ||
return rootReject(readDirErr); | ||
} | ||
|
||
return Promise.all( | ||
readDirResult.files | ||
.filter(inFile => path.extname(inFile) === path.extname(inFileName)) | ||
.map(inFile => { | ||
const inDir = path.dirname(inFile); | ||
const relativeInDir = path.relative(inRootDir, inDir); | ||
const outDir = path.resolve(outRootDir, relativeInDir); | ||
const outFile = path.resolve(outDir, outFileName); | ||
|
||
return new Promise((resolve, reject) => { | ||
mkdirp(outDir, (mkdirpErr) => { | ||
if (mkdirpErr) { | ||
return reject(mkdirpErr); | ||
} | ||
|
||
fs.readFile(inFile, 'utf-8', (readFileErr, readFileResult) => { | ||
if (readFileErr) { | ||
return reject(readFileErr); | ||
} | ||
|
||
less.render(readFileResult, lessOptions, (lessErr, lessResult) => { | ||
if (lessErr) { | ||
return reject(lessErr); | ||
} | ||
|
||
fs.writeFile(outFile, lessResult.css, 'utf-8', (writeFileErr) => { | ||
if (writeFileErr) { | ||
return reject(writeFileErr); | ||
} | ||
|
||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}) | ||
).then(rootResolve); | ||
}); | ||
}); | ||
} |
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,5 @@ | ||
export function cleanBuild() { | ||
const del = require('del'); | ||
|
||
return del([ 'build/' ]); | ||
} |
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,7 @@ | ||
export { cleanBuild } from './clean'; | ||
export { lessBuild } from './build'; | ||
|
||
export const build = [ | ||
exports.cleanBuild, | ||
exports.lessBuild | ||
]; |