| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- const fs = require('fs');
- const path = require('path');
- const { exec } = require('child_process');
- const Promise = require('bluebird');
- const examplesDir = path.normalize(__dirname + '/../exemples');
- const listJson = require('./exemples/liste.json');
- Promise.promisifyAll(fs);
- // Promisified exec
- function execAsync(cmd) {
- return new Promise((resolve, reject) => {
- exec(cmd, (error, stdout, stderr) => {
- if (error) {
- return reject(error);
- }
- resolve({ stdout, stderr });
- });
- });
- }
- // Promisified exec of git mv src dst
- function gitMvAsync(src, dst) {
- var cmd = 'git mv ' + src + ' ' + dst;
- execAsync(cmd)
- .then(({stdout, stderr}) => {
- console.log(`stdout: ${stdout}`);
- console.log(`stderr: ${stderr}`);
- })
- .catch(error => {
- console.error(`exec error: ${error}`);
- throw error;
- });
- }
- // execAsync('git status')
- // .then(({stdout, stderr}) => {
- // console.log(`stdout: ${stdout}`);
- // console.log(`stderr: ${stderr}`);
- // })
- // .catch(error => {
- // console.error(`exec error: ${error}`);
- // });
- // rename all examples' html
- // fs.readdirAsync(examplesDir)
- // .then(dirContent => {
- // var excludes = ['liste.json', '.gitkeep', 'start-iframe.html', 'template.html'];
- // excludes.forEach(file => {
- // var idxInContent = dirContent.indexOf(file);
- // if(idxInContent !== -1) {
- // dirContent.splice(idxInContent, 1);
- // }
- // });
- // return dirContent;
- // })
- // .then(dirContent => Promise.map(dirContent, dir => {
- // const fullPath = examplesDir + '/' + dir;
- // const src = fullPath + '/contenu.html';
- // const dst = fullPath + '/example.html';
- // gitMvAsync(src, dst)
- // })
- // )
- // .catch(console.error);
|