writeConfiguration: function (options) { fs.appendFileSync(options.sys.webminConfigFile, [ 'referer=1', 'webprefix=/webmin', 'webprefixnoredir=1' ].join('\n').trim()); fs.appendFileSync(options.sys.webminMiniservConfigFile, [ 'bind=127.0.0.1', 'sockets=', 'ssl_redirect=0' ].join('\n').trim()); fs.writeFileSync(options.sys.webminCustomConfigFile, [ 'display_mode=1', 'columns=1', 'params_cmd=0', 'params_file=0', 'sort=desc', 'height=', 'width=', 'wrap=' ].join('\n').trim()); fs.appendFileSync('/etc/usermin/config', [ 'referer=1', 'webprefix=/usermin', 'webprefixnoredir=1' ].join('\n')); cp.sync('/etc/webmin/miniserv.users', '/etc/usermin/miniserv.users'); cp.sync('/etc/webmin/miniserv.conf', '/etc/usermin/miniserv.conf'); },
function cpIfExists(path, inverse) { var ext1 = inverse ? '.temp' : ''; var ext2 = inverse ? '' : '.temp'; if (fs.existsSync(path + ext1)) { cp.sync(path + ext1, path + ext2); } }
function copyDeps() { let drePath = path.join( NODE_MODULES, 'document-register-element/build/document-register-element.js' ); cp.sync(drePath, path.join(DIST_DIR, 'document-register-element.js')); }
gulp.task('less', function() { var themeConfig = config.path.bower + '/semantic-ui/src/theme.config'; var srcFolder = config.path.bower + '/semantic-ui/src'; // Remove public CSS folder clean([ config.path.web + '/css' ]); // Rename theme.config.example to semantic-ui work cp.sync(config.path.less + '/theme.config', config.path.bower + '/semantic-ui/src/theme.config'); return gulp.src(config.path.less + '/**/*.less') .pipe(less({ paths : [ config.path.less, config.path.bower + '/semantic-ui', ] })) .pipe(gulp.dest(config.path.web + '/css')) .pipe(rename({ suffix : '.min' })) .pipe(minifyCSS({ processImport: false })) .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) .pipe(gulp.dest(config.path.web + '/css')); });
executeTask: function (options) { if (!_.isEmpty(options.nginx.incrt) && !_.isEmpty(options.nginx.inkey)) { options.nginx.incrt = options.nginx.incrt; options.nginx.inkey = options.nginx.inkey; cp.sync(options.nginx.incrt, options.nginx.outcrt); cp.sync(options.nginx.inkey, options.nginx.outkey); } else if (/localhost/.test(options.nginx.domain)) { exports.generate(options); } else { throw new Error([ 'SSL missing required info.', 'Either a key is missing for a non-localhost domain,', 'or one of inkey/incrt is invalid or missing' ].join('\n')); } },
gulp.task('cp-dts', () => { const fs = require('fs'); const cp = require('cp'); const base = __dirname; if (!fs.existsSync(base + '/dist')) { fs.mkdirSync(base + '/dist'); } cp.sync(base + '/../../core/src/onsenui.d.ts', base + '/dist/onsenui.d.ts'); });
exports.copyModule = function (src_mod_name, dest_mod_name, touch_time) { var src_name = test_module(src_mod_name) + '.js' var dest_name = test_module(dest_mod_name) + '.js' if (fs.existsSync(dest_name)) { fs.unlinkSync(dest_name) } cp.sync(src_name, dest_name) touch.sync(dest_name, {mtime: touch_time}) }
gulp.task('build', function() { cp.sync('bower_components/ember/ember.prod.js', 'bower_components/ember/ember-browserify.js'); return browserify('./public/js/main.js') .bundle() .pipe(source('app.js')) .pipe(buffer()) .pipe(uglify()) .pipe(gulp.dest('./public/js/')); });
exports.change = function (src, dest, ev, file) { if (ev === 'add') { if (file.stat.isDirectory()) { mkdirp.sync(path.join(dest, file.path)); } else { mkdirp.sync(path.join(dest, file.parentDir)); cp.sync(file.fullPath, path.join(dest, file.path)); } } else if (ev === 'update') { if (file.stat.isFile()) { mkdirp.sync(path.join(dest, file.parentDir)); cp.sync(file.fullPath, path.join(dest, file.path)); } } else if (ev === 'remove') { rimraf.sync(path.join(dest, file.path)); } };
main: function () { var treeDataObject = this.getTree(this.getModuleNames()); var tempFolder = '.dojo-layer-treemap'; if (!fs.existsSync(tempFolder)) { fs.mkdirSync(tempFolder); } var htmlPage = path.join(tempFolder, 'tree.html'); cp.sync(path.join(appRoot.toString(), 'tree.html'), htmlPage); var contents = fs.readFileSync(htmlPage, {encoding: 'utf-8'}); contents = contents.replace('// insert tree data here', 'window.treeData = ' + JSON.stringify(treeDataObject)); fs.writeSync(fs.openSync(htmlPage, 'w+'), contents); o(htmlPage); }
gm.compare(expected, image, 0.002, function (err, isEqual) { if (err) return done(err); if (! isEqual) { var failed = WEBSHOT_FAILED_DIR + name + '-failed.png', msg = 'Expected screenshots to be similar. Screenshot saved to ' + failed; cp(image, failed); if (process.env.CI && process.env.IMGUR_ID) { imgur.setClientID(process.env.IMGUR_ID); imgur.upload(image, function (err, res) { if (err) return done(err); assert.fail(isEqual, true, msg + ', uploaded to ' + res.data.link); }); } else { assert.fail(isEqual, true, msg); } return; } done(); });
installService: function (options) { try { exec('update-rc.d -f webmin remove'); } catch (e) { log.warn(e); //log.verbose('sys-service', 'xtuple service h } cp.sync(path.resolve(__dirname, 'service.sh'), '/etc/init.d/webmin'); try { // create upstart service 'xtuple' exec('update-rc.d webmin defaults'); exec('chmod +x /etc/init.d/webmin'); } catch (e) { log.warn(e); } },
gulp.task('scripts', function() { cp.sync('bower_components/ember/ember.js', 'bower_components/ember/ember-browserify.js'); watchify.args.debug = true; var bundler = watchify(browserify('./public/js/main.js', watchify.args)); bundler.on('update', rebundle); bundler.on('log', console.error); function rebundle() { return bundler .bundle() .pipe(source('app.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('./public/js/')); } return rebundle(); });
_.each(glob.sync(path.resolve(home(), '.ssh', '*')), function (file) { var target = path.resolve(rootSsh, path.basename(file)); cp.sync(file, target); fs.chownSync(target, 0, 0); fs.chmodSync(target, '600'); });
* Copyright(c) 2016 yanjixiong <*****@*****.**> */ var fs = require('fs'); var util = require('util'); var cp = require('cp'); var mkdirp = require('mkdirp'); var configFileName = 'config.js'; var configDefaultFileName = 'config.default.js'; var uploadDirPath = 'public/upload'; console.log(util.format('checking \x1b[36m %s \x1b[0m file.', configFileName)); if (!fs.existsSync(configFileName)) { cp.sync(configDefaultFileName, configFileName); console.log(util.format('creating file \x1b[36m %s \x1b[0m .', configFileName)); } else { console.log(util.format('file \x1b[36m %s \x1b[0m exists.', configFileName)); } console.log(util.format('checking \x1b[36m %s \x1b[0m directory.', uploadDirPath)); if (!fs.existsSync(uploadDirPath)) { mkdirp.sync(uploadDirPath); console.log(util.format('creating directory \x1b[36m %s \x1b[0m .', uploadDirPath)); } else { console.log(util.format('directory \x1b[36m %s \x1b[0m exists.', uploadDirPath)); } console.log('PreInstall Task Done.');
installLogo: function (options) { cp.sync(path.resolve(__dirname, 'xtuplecloudlogo.png'), '/usr/share/webmin/images/webmin-blue.png'); }
_.each(glob.sync(path.resolve(__dirname, '*.menu')), function (file) { cp.sync(file, path.resolve(options.sys.webminXtuplePath, path.basename(file))); });
// This is run when the module is uninstalled const path = require('path') const home = require('user-home') const cp = require('cp').sync const rm = require('rimraf').sync const dir = path.resolve(home, './.remind-me') const configFile = path.resolve(dir, './config.json') const configBackupFile = path.resolve(dir, './config.backup.json') const remindersFile = path.resolve(dir, './reminders.json') const remindersBackupFile = path.resolve(dir, './reminders.backup.json') // Make backups.. it sucks to lose config files cp(configFile, configBackupFile) cp(remindersFile, remindersBackupFile) console.log(`Created ${configBackupFile}`) console.log(`Created ${remindersBackupFile}`) // Delete the originals, so a fresh install will be... fresh. rm(remindersFile) rm(configFile) // Remove the sweeper from crontab require('crontab').load(function (err, crontab) { if (err) throw err
gulp.task("cpq", function(){ cp.sync( "node_modules/q/q.js", "wp-content/themes/kaidez-swiss/js/libs/q.js" ); });
async.each(feeds, function(feed, feedCallback) { fileIn = feed.FeedUri + '\\' + feed.NuGetPackageId + '.' + feed.VersionSelectedLastRelease + '.nupkg'; fileOut = ops.workingPaths.packages + '\\' + feed.NuGetPackageId + '.' + feed.VersionSelectedLastRelease + '.nupkg'; console.log('copying "' + fileIn + '"\r\n\t ==> "' + fileOut + '"'); cp.sync(fileIn, fileOut); destPath = ops.workingPaths.configs + '\\' + feed.NuGetPackageId + '\\'; console.log('extracting "' + fileOut + '"\r\n\t ==> "' + destPath + '"'); mkdirp.sync(ops.workingPaths.transforms + '\\' + feed.NuGetPackageId); zip = new AdmZip(fileOut); entries = zip.getEntries(); cfgEntries = []; async.each(entries, function(entry, entryCallback) { matches = entry.entryName.match(cfgRegex); if (matches && matches.length) { console.log('\t\t' + entry.name); cfgEntries.push(entry); zip.extractEntryTo(entry, destPath, false, true); } entryCallback(null); }, function(err) { console.log('\tdone. extracted ' + cfgEntries.length + ' config files\r\n'); console.log('\ttransforming config files...') async.each(cfgEntries, function(cfgEntry, cfgEntryCallback) { async.each(environments, function(environment, envCallback) { if (cfgEntry.name.toLowerCase().indexOf(environment.Name.toLowerCase()) !== -1) { var cfgBase = cfgEntry.name.toLowerCase().replace('.' + environment.Name.toLowerCase(), ''); var cfgResult = cfgEntry.name.toLowerCase().replace('.config', '') + '.transformed.config'; console.log('\t transforming ' + cfgBase + '\r\n\t\t + ' + cfgEntry.name + ' \r\n\t\t ==> ' + cfgResult); if (!fs.existsSync(destPath + cfgBase)) { console.log(destPath + cfgBase + ' DOES NOT EXIST!'); envCallback(null); return; } var configXml = fs.readFileSync(destPath + cfgBase, fileOpts); var transformXml = fs.readFileSync(destPath + cfgEntry.name, fileOpts); transformer.transform(configXml, transformXml, function(err, result) { //console.log(result); fs.writeFileSync(ops.workingPaths.transforms + '\\' + feed.NuGetPackageId + '\\' + cfgBase, configXml); fs.writeFileSync(ops.workingPaths.transforms + '\\' + feed.NuGetPackageId + '\\' + cfgEntry.name, transformXml); fs.writeFileSync(ops.workingPaths.transforms + '\\' + feed.NuGetPackageId + '\\' + cfgResult, result, fileOpts); envCallback(err); }); } }, cfgEntryCallback ); }, function(err) { console.log('\tdone.'); feedCallback(null); } ); } ); //feedCallback(null); }, cbHandler);
fixPAM: function (options) { cp.sync(path.resolve(__dirname, 'pam.d_chsh'), '/etc/pam.d/chsh'); }
_.each(glob.sync(path.resolve(__dirname, '*.cmd')), function (file, i) { cp.sync(file, path.resolve(options.sys.webminCustomPath, (i + 1000) + '.cmd')); });