How to use the touch.sync function in touch

To help you get started, we’ve selected a few touch 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 DefinitelyTyped / DefinitelyTyped / types / touch / touch-tests.ts View on Github external
opts.atime = boolVal;
opts.atime = dateVal;

opts.mtime = boolVal;
opts.mtime = dateVal;

opts.ref = strVal;

opts.nocreate = boolVal;

// touch API tests
touch(strVal, (e) => console.log(e));
touch(strVal, opts, (e) => console.log(e));

touch.sync(strVal);
touch.sync(strVal, opts);

// ftouch API tests
touch.ftouch(numVal, (e) => console.log(e));
touch.ftouch(numVal, opts, (e) => console.log(e));

touch.ftouch.sync(numVal);
touch.ftouch.sync(numVal, opts);

touch.ftouchSync(numVal);
touch.ftouchSync(numVal, opts);
github chaijs / chai-fs / test / init.js View on Github external
chai.use(require('chai-json-schema'));

//var expect = chai.expect;
var assert = chai.assert;

// import assertion multi tester
require('./tester')(chai, _);

// create some empty dirs (cannot check-in empty dirs to git)
mkdirp.sync('./test/tmp');
mkdirp.sync('./test/fixtures/empty');
mkdirp.sync('./test/fixtures/dir/.dotdir/empty');
mkdirp.sync('./test/fixtures/dir-copy/.dotdir/empty');

// change the times of alpha-copy.txt, so it will be equal, but not DEEP equal to alpha.txt
touch.sync('./test/fixtures/alpha-copy.txt', {time: '2016-01-01T00:00:00Z'});

// delete files that get created automatically by the OS (they mess-up directory listings)
del.sync('test/fixtures/**/.DS_Store', {dot: true});
del.sync('test/fixtures/**/Thumbs.db', {dot: true});

describe('initialized', function () {
	assert.isDirectory('./test/tmp');
	assert.isDirectory('./test/fixtures');
	assert.isDirectory('./test/fixtures/empty');
	assert.isDirectory('./test/fixtures/dir/.dotdir/empty');
	assert.isDirectory('./test/fixtures/dir-copy/.dotdir/empty');
});

describe('chai-fs', function () {
	it('exports module', function () {
		assert.isFunction(chai_fs, 'chai_fs export');
github Inist-CNRS / node-inotifywait / test / inotifywait.js View on Github external
w.on('ready', function () {
      touch.sync(f_dst); // touch the hard link
    });
  });
github reframejs / goldpage / helpers / file-sets / index.js View on Github external
if( no_changes ) {
            return filePath;
        }

        (global.DEBUG||{}).WATCH && console.log('NEW-FILE-CONTENT: '+filePath);

        fs__write_file(filePath, fileContent);

        if( ! noFileSet && session_object.is_first_session ) {
            // Webpack bug fix
            //  - https://github.com/yessky/webpack-mild-compile
            //  - https://github.com/webpack/watchpack/issues/25
            //  - alternative solution: `require('webpack-mild-compile')`
            const twelve_minutes = 1000*60*12;
            const time = new Date() - twelve_minutes;
            touch.sync(filePath, {time});
        }

        return filePath;
    }
github coderafei / wechat-bot / weixinbot.js View on Github external
const FileCookieStore = require('tough-cookie-filestore');
const axiosCookieJarSupport = require('node-axios-cookiejar');

const {
  getUrls, CODES, SP_ACCOUNTS, PUSH_HOST_LIST,
} = require('./conf');

Promise.promisifyAll(Datastore.prototype);
const debug = Debug('weixinbot');

let URLS = getUrls({});
const logo = fs.readFileSync(path.join(__dirname, 'logo.txt'), 'utf8');

// try persistent cookie
const cookiePath = path.join(process.cwd(), '.cookie.json');
touch.sync(cookiePath);
const jar = new tough.CookieJar(new FileCookieStore(cookiePath));

const req = axios.create({
  timeout: 35e3,
  headers: {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) ' +
      'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2652.0 Safari/537.36',
    'Referer': 'https://wx2.qq.com/',
  },
  jar,
  withCredentials: true,
  xsrfCookieName: null,
  xsrfHeaderName: null,
  httpAgent: new http.Agent({ keepAlive: true }),
  httpsAgent: new https.Agent({ keepAlive: true }),
github airyland / vux-loader / src / template-loader.js View on Github external
// all and yml format
              if (fileMode === 'all' && format === 'yml') {
                touch.sync(savePath)
                let currentConfig = fs.readFileSync(savePath, 'utf-8')
                if (!currentConfig) {
                  finalConfig = rs.translations
                } else {
                  finalConfig = mergeLang(yamlReader.safeLoad(currentConfig), rs.translations)
                }
                if (!currentConfig || (currentConfig && JSON.stringify(yamlReader.safeLoad(currentConfig)) !== JSON.stringify(finalConfig))) {
                  fs.writeFileSync(savePath, yamlReader.safeDump(finalConfig))
                }
              }

              if (fileMode === 'all' && format === 'json') {
                touch.sync(savePath)
                let currentConfig = fs.readFileSync(savePath, 'utf-8')
                if (!currentConfig) {
                  finalConfig = rs.translations
                } else {
                  finalConfig = mergeLang(JSON.parse(currentConfig), rs.translations)
                }
                if (!currentConfig || (currentConfig && JSON.stringify(currentConfig) !== JSON.stringify(finalConfig))) {
                  fs.writeFileSync(savePath, JSON.stringify(finalConfig, null, 2))
                }
              }

              // single and yml

              if (fileMode === 'single' && format === 'yml') {
                for (let i = 0; i < langs.length; i++) {
                  let lang = langs[i]
github spmjs / serve-spm / test / parser.js View on Github external
it('isModified', function() {
    var file = join(root, 'index.js');
    var ltime = mtime(file);
    var p;

    p = new Parser(extend(args, {
      req: {pathname: '/index.js'},
      headers: {
        'if-modified-since': ltime
      }
    }));
    p.isModified().should.be.false;

    touch.sync(file);
    p = new Parser(extend(args, {
      req: {pathname: '/index.js'},
      headers: {
        'if-modified-since': ltime
      }
    }));
    p.isModified().should.be.true;

    function mtime(filepath) {
      return new Date(fs.statSync(filepath).mtime);
    }
  });
github typicode / katon / src / cli / commands / kill.js View on Github external
module.exports = function(args) {
  var host = args[0] || path.basename(process.cwd())
  var file = config.hostsDir + '/' + host + '.json'
  if (fs.existsSync(file)) {
    touch.sync(file)
    console.log('%s has been successfully reloaded', chalk.cyan(host))
  } else {
    console.log("Can\'t find %s, use katon list", chalk.red(host))
  }
}
github lazywithclass / swaggins / lib / swagger.js View on Github external
exports.writeResponse = (req) => {
  var file = 'swagger.json';
  touch.sync(file);
  var json = fs.readFileSync(file, 'utf8');
  json = json ? JSON.parse(json) : init();

  var converted = convert(req.res);
  json.paths[converted.path] = json.paths[converted.path] || {};
  json.paths[converted.path][converted.method] =
    _.merge(json.paths[converted.path][converted.method], converted.call);
  json.definitions = json.definitions || {};

  if (converted.definition)
    json.definitions[converted.definitionKey] =
    converted.definition[converted.definitionKey];

  fs.writeFileSync(file, JSON.stringify(json, null, '  '));
}

touch

like touch(1) in node

ISC
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis