Add babel
This commit is contained in:
@@ -4,14 +4,16 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"create": "node ./scripts/create.js",
|
"create": "npm run clean && babel-node ./scripts/create.js",
|
||||||
"clean": "node ./scripts/clean.js",
|
"clean": "babel-node ./scripts/clean.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "Tom Raithel <t.raithel@googlemail.com> (http://www.tomraithel.de)",
|
"author": "Tom Raithel <t.raithel@googlemail.com> (http://www.tomraithel.de)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "2.1.4",
|
"async": "2.1.4",
|
||||||
|
"babel-cli": "6.22.2",
|
||||||
|
"babel-preset-latest": "6.22.0",
|
||||||
"front-matter": "2.1.1",
|
"front-matter": "2.1.1",
|
||||||
"fs-extra": "2.0.0",
|
"fs-extra": "2.0.0",
|
||||||
"marked": "0.3.6"
|
"marked": "0.3.6"
|
||||||
|
|||||||
@@ -1,24 +1,14 @@
|
|||||||
var fs = require('fs-extra');
|
import { emptyDir } from 'fs-extra';
|
||||||
var async = require('async');
|
import { distPath } from './file';
|
||||||
var file = require('./file');
|
|
||||||
|
|
||||||
var distDir = file.distDir();
|
var distDir = distPath();
|
||||||
|
|
||||||
console.log('<<< start cleaning dist dir: ', distDir);
|
console.log('<<< start cleaning dist dir: ', distDir);
|
||||||
|
|
||||||
async.series([
|
emptyDir(distDir, (err) => {
|
||||||
function(callback) {
|
|
||||||
fs.ensureDir(distDir, callback);
|
|
||||||
},
|
|
||||||
function(callback) {
|
|
||||||
fs.emptyDir(distDir, callback);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
function(err, results) {
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
console.log('done cleaning dist dir >>>');
|
console.log('done cleaning dist dir >>>');
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,21 +1,35 @@
|
|||||||
var fs = require('fs-extra');
|
import {
|
||||||
var frontmatter = require('front-matter');
|
readFile,
|
||||||
var marked = require('marked');
|
outputFile,
|
||||||
var file = require('./file');
|
} from 'fs-extra';
|
||||||
|
import frontmatter from 'front-matter';
|
||||||
|
import marked from 'marked';
|
||||||
|
import waterfall from 'async/waterfall';
|
||||||
|
import {
|
||||||
|
srcPath,
|
||||||
|
distPath,
|
||||||
|
} from './file';
|
||||||
|
|
||||||
var fileName = file.path('radar/v1/tools/grunt.md');
|
const fileName = srcPath('v1/tools/grunt.md');
|
||||||
|
|
||||||
fs.readFile(fileName, 'utf8', function(err, data) {
|
console.log('<<< start creating files');
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
var item = frontmatter(data);
|
waterfall([
|
||||||
|
(callback) => {
|
||||||
|
readFile(fileName, 'utf8', callback);
|
||||||
|
},
|
||||||
|
(data, callback) => {
|
||||||
|
const item = frontmatter(data);
|
||||||
|
const html = marked(item.body);
|
||||||
|
|
||||||
var html = marked(item.body);
|
outputFile(distPath('test3.html'), html, callback);
|
||||||
|
}
|
||||||
console.log(item.attributes);
|
],
|
||||||
console.log(html);
|
(err, results) => {
|
||||||
|
if (!err) {
|
||||||
fs.outputFile(file.distDir() + '/test.html', html, function (err) {
|
console.log('done creating files >>>');
|
||||||
console.log(err) // => null
|
} else {
|
||||||
})
|
console.error(err);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
var path = require('path');
|
import path from 'path';
|
||||||
|
|
||||||
module.exports = {
|
export const relativePath = (...relativePath) => (
|
||||||
path: function(relativePath) {
|
path.resolve(__dirname, '..', ...relativePath)
|
||||||
return path.resolve(__dirname, '..', relativePath)
|
);
|
||||||
},
|
|
||||||
distDir: function() {
|
export const srcPath = (pathInSrc = '') => (
|
||||||
return this.path('dist');
|
relativePath('radar', pathInSrc)
|
||||||
}
|
);
|
||||||
};
|
|
||||||
|
export const distPath = (pathInDist = '') => (
|
||||||
|
relativePath('dist', pathInDist)
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user