How to use ncp - 10 common examples

To help you get started, we’ve selected a few ncp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thatcort / git-gallery / bin / main.js View on Github external
function init() {
	// create the .gitGallery directory
	fs.mkdirSync(galleryRoot);

	// copy in the views directory
	let sourceViews = path.join(__dirname, '../views');
	let destViews = path.join(galleryRoot, 'views');
	ncp(sourceViews, destViews, { "clobber": false }, error => { if (error) console.error(error); });

	// add a gallery.json file
	let gjFile = path.join(galleryRoot, 'gallery.json');
	fsUtils.writeJson({ 'title': '', 'comment': '', 'showCanvas': false }, gjFile, { 'flag': 'wx' }, error => { if (error) console.log(error); });

	// create/edit .gitignore file
	let gitignore = path.join(galleryRoot, '../.gitignore');
	fs.ensureFileSync(gitignore);
	var rd = readline.createInterface({
		input: fs.createReadStream(gitignore),
		output: process.stdout,
		terminal: false
	});
	let alreadyIgnored = false;
	rd.on('line', function(line) {
		if (line.indexOf('.gitGallery') >= 0)
github AmitMY / redux-viewer / bin / run.js View on Github external
let directory;
// Make sure there is a directory passed
if (!args.source) {
  console.error('Must pass a folder!');
  process.exit();
} else {
  directory = args.source;
}


const fs = require('fs'); // File system to write a JSON
const path = require('path'); // Path resolving
const findInFiles = require('find-in-files'); // File regex lookup
const ncp = require('ncp').ncp;

ncp.limit = 16;
ncp(path.join(__dirname, '../node_modules/force-horse/dist'), path.join(__dirname, '../viewer/force-horse'));

// Regex describing an effect
const regexSearch = new RegExp(/\/\*\*([\s\S]*?)\@type Effect([\s\S]*?)\*\//);

// Run file lookup
findInFiles.find(regexSearch, directory, '.ts$').then(result => {
  let effects = [];

  Object.keys(result).forEach(file => {
    result[file].matches.forEach(match => {
      let matchArray = match.split('\n')
        .map(l => l.trim())
        .map(l => l.substr(2, l.length - 2))
        .map(l => l.split(' '))
        .map(l => ({param: l.shift(), body: l.join(' ')}))
github Nishkalkashyap / Quark-electron / copyicons.js View on Github external
function copyFiles() {
                var mkdirp = require('mkdirp');
                mkdirp('./definitions/' + val, function (e) {
                    if (e) {
                        console.log(e);
                    }
                });
                ncp.ncp("./node_modules/" + val, './definitions/' + val, {
                    filter: function (file) {
                        return (((fs.statSync(file).isDirectory() || file.includes('.d.ts') || file.endsWith('package.json'))
                            && (!file.replace('node_modules', '').includes('node_modules')))
                            // && (file.search(/api[\\/]umd/) == -1)
                            && (file.search('.git') == -1));
                    },
                    dereference: true
                }, function (e) {
                    if (e) {
                        console.log(e, 'failed');
                    }
                });
            }
        });
github orchoban / react.cordova / node_modules / .cache / esm / f1f70fc214a5a573.js View on Github external
? "./" : dirPath1.substring(0, dirPath1.indexOf("/cordova")) + "/"

                    ncp(parentDir + "react-js/build", parentDir + "cordova/www", function (err) {
                        if (err) {
                            reco.setState({ error: true });
                            return console.error("ERROR ncp1, copy react-js/build tocordova/www :   " + err);
                        }
                        reco.state.callBack_replaceWwwRootDir(); // callBack();
                    });
                }

            }
            rmWwwRootDir(dirPath1);
        } else {
            let parentDir = dirPath1.startsWith("./cordova") ? "./" : dirPath1.substring(0, dirPath1.indexOf("/cordova")) + "/";
            ncp(parentDir + "react-js/build", parentDir + "cordova/www", function (err) {
                if (err) {
                    reco.setState({ error: true });
                    return console.error("ERROR ncp2, copy react-js/build tocordova/www :   " + err);
                }
                reco.state.callBack_replaceWwwRootDir(); // callBack();
            });
        }

    },
github tingbot / tide-electron / index.html View on Github external
e.preventDefault();
        var file = e.dataTransfer.files[0];
        console.log(file);
        console.log('File you dragged here is', file.path);
        ipcRenderer.send("fileAdd", file);

        return false;
      };

      // directory stuff
      var fs = require('fs');

      var path = require('path');
      var ncp = require('ncp').ncp;

      ncp.limit = 16;

      function saveDir(source, destination, cb) {
        var destpath = path.parse(destination);
        fs.mkdir(destpath.dir, function() {
          ncp(source, destination, function(err) {
            if (err) {
              return console.error(err);
            }
            console.log(destination);
            cb(destination);
          });
        });

      }

      //load specific .tingapp into the view
github vscode-icons / vscode-icons / src / build / build.js View on Github external
var ncp = require('ncp').ncp;
var iconGenerator = require('./iconGenerator');

var outDir = './dist';

// generating icons.json
// The function takes as second argument the directory where
// we want the file to be placed.
// Default directory is the 'root' directory

iconGenerator.generate('icons.json', outDir);

// moving to dist
ncp.limit = 16;
ncp('./src/dev', outDir, function (err) {
  if (err) {
    console.error(err);
    return;
  }
  console.log('Build completed!'); //eslint-disable-line
});
github orchoban / react.cordova / bin / reco2 / init.js View on Github external
}).on('close', function () {
                                                                                                                        // end!!!
                                                                                                                        if (!reco.state.error) {
                                                                                                                            reco.succeeded();
                                                                                                                            console.log();
                                                                                                                            console.log("run 'cd " + rootDir + "'")
                                                                                                                        }

                                                                                                                    });
                                                                                                            });



                                                                                                    });
                                                                                                });
                                                                                                ncp.limit = 9999999999999999999;


                                                                                            }
                                                                                        });
                                                                                    });
github ging / ediphy / doc / scripts / bringtodist.js View on Github external
const path = require('path');
const fs = require('fs');
const ncp = require("ncp").ncp;

const origPath = path.join('.', 'dist/lib');
const dstPath = path.join('.', 'doc/dist/demo/lib');
ncp.limit = 0;

const mkdirSync = function(dirPath) {
    try {
        fs.mkdirSync(dirPath);
    } catch (err) {
        if (err.code !== 'EEXIST') {throw err;}
    }
};

mkdirSync(dstPath);
ncp(origPath, dstPath, function(err) {
    if (err) {
        // eslint-disable-next-line no-console
        return console.error(err);
    }
github machawk1 / wail / tools / prepairBuild.js View on Github external
import ncp from 'ncp'

const buildPath = path.join(path.resolve('../'), 'electron/build')
const basePath = path.join(path.resolve('../'), 'electron/src')
const actions = path.join(basePath, 'js/actions')
const components = path.join(basePath, 'js/components')
const constants = path.join(basePath, 'js/constants')
const dispatchers = path.join(basePath, 'js/dispatchers')
const stores = path.join(basePath, 'js/stores')
const pub = path.join(basePath, 'public')
const app = path.join(buildPath, 'app')

console.log(basePath)
fs.ensureDir(app, err => console.log(err))

ncp(basePath, app, err => console.log(err))

// dirs.forEach(dir => fs.ensureDir(dir, err => console.log(dir)))
github leo / cory / bin / build.js View on Github external
builder.build().then(results => {
    const dir = typeof results === 'string' ? results : results.directory
    let buildTime = results.totalTime

    // Copy files from tmp folder to the destination directory
    // And make sure to follow symlinks while doing so
    ncp(dir, config.outputDir + '/assets', {dereference: true}, err => {
      if (err) {
        throw err
      }

      if (buildTime) {
        // The original built time is in nanoseconds, so we need to convert it to milliseconds
        buildTime += initialBuild
        console.log(chalk.green(`Finished building after ${Math.floor(buildTime / 1e6)}ms.`))
      } else {
        console.log(chalk.green('Finished building.'))
      }

      if (!options.watch) {
        builder.cleanup().catch(err => console.error(err))
      }
    })

ncp

Asynchronous recursive file copy utility.

MIT
Latest version published 9 years ago

Package Health Score

72 / 100
Full package analysis