How to use the mz/fs.existsSync function in mz

To help you get started, we’ve selected a few mz 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 flutter-view / flutter-view / src / watcher.ts View on Github external
switch(extname(file)) {
			case '.pug': {
				html = renderPugFileAsHtml(file)
				// html = await renderFile(file)
				break
			}
			case '.htm': case '.html': {
				html = fs.readFileSync(file).toString()
				break
			}
			case '.css': case '.sass': {
				if(isUpdate) {
					const p = parseFileName(relative(process.cwd(), file))
					const pugFile = `${p.dir}/${p.name}.pug`
					const htmlFile = `${p.dir}/${p.name}.html`
					if(fs.existsSync(pugFile)) {
						return await processFile(pugFile, isUpdate)
					} else if(fs.existsSync(htmlFile)) {
						return await processFile(htmlFile, isUpdate)
					}
				}
				return null
			}
		}

		if(!html) {
			if(options.debug && options.debug.logHTML) 
				console.debug(`no html found in file ${file}`)
			return null
		}

		if(options.debug && options.debug.logHTML)
github flutter-view / flutter-view / src / watcher.ts View on Github external
html = renderPugFileAsHtml(file)
				// html = await renderFile(file)
				break
			}
			case '.htm': case '.html': {
				html = fs.readFileSync(file).toString()
				break
			}
			case '.css': case '.sass': {
				if(isUpdate) {
					const p = parseFileName(relative(process.cwd(), file))
					const pugFile = `${p.dir}/${p.name}.pug`
					const htmlFile = `${p.dir}/${p.name}.html`
					if(fs.existsSync(pugFile)) {
						return await processFile(pugFile, isUpdate)
					} else if(fs.existsSync(htmlFile)) {
						return await processFile(htmlFile, isUpdate)
					}
				}
				return null
			}
		}

		if(!html) {
			if(options.debug && options.debug.logHTML) 
				console.debug(`no html found in file ${file}`)
			return null
		}

		if(options.debug && options.debug.logHTML) 
			console.debug(relativeFile, 'HTML:\n' + html)
github RobotWebTools / rclnodejs / rosidl_gen / generator.js View on Github external
isRootGererated() {
    // eslint-disable-next-line
    return fs.existsSync(generatedRoot);
  },
github flutter-view / flutter-view / src / watcher.ts View on Github external
function loadOptions() {
		options = clone(defaultOptions)
		if(fs.existsSync(configFileName)) {
			const loadedOptions = JSON.parse(fs.readFileSync(configFileName).toString())
			options = merge(options, loadedOptions)
		}
		plugins = []
		if(options && options.plugins) {
			for(let plugin of options.plugins) {
				try {
					const pluginFn = require(plugin)
					plugins.push(pluginFn)
				} catch(e) {
					console.error(`error loading ${plugin}`, e)
				}
			}
		}
	}
github macacajs / macaca-datahub / app / service / database.js View on Github external
async importSchema(baseDir) {
    if (!fs.existsSync(baseDir)) return;
    const contents = await fs.readdir(baseDir);
    await Promise.all(contents.map(async content => {
      const buffer = await fs.readFile(path.join(baseDir, content));
      const data = JSON.parse(buffer);
      await this.ctx.model.Schema.upsert(data);
    }));
  }
github JoshuaKGoldberg / TypeStat / src / services / language.ts View on Github external
getScriptSnapshot: (fileName) =>
            fs.existsSync(fileName) ? ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : undefined,
        getScriptVersion: () => "0",
github CMSgov / design-system / tools / gulp / stats / stats.js View on Github external
.then(body => {
      if (!fs.existsSync(tmpPath)) {
        fs.mkdir(tmpPath).then(() => body);
      }

      return body;
    })
    .then(body => fs.writeFile(outputPath, body, 'utf8'))
github JoshuaKGoldberg / TypeStat / src / services / language.ts View on Github external
getScriptSnapshot: (fileName) =>
            fs.existsSync(fileName) ? ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : undefined,
        getScriptVersion: () => "0",