当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs.appendFile函数代码示例

本文整理汇总了TypeScript中fs.appendFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript appendFile函数的具体用法?TypeScript appendFile怎么用?TypeScript appendFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了appendFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: appendFile

    return new Promise<void>((resolve, reject) => {
      // Do filesystem stuff
      const lineStr = `${JSON.stringify(line)}\n`;
      appendFile(
        joinPath(
          '.',
          this.dir,
          `${this.currentId}.log`,
        ),
        lineStr,
        (err) => {
          if (err) {
            reject(err);
            return;
          }
          resolve();
        });

      // Add to cache
      if (!this.cache.has(this.currentId)) {
        this.cache.set(this.currentId, []);
      }
      const set = this.cache.get(this.currentId);
      set.push(line);
      if (set.length >= this.maxLogLength) {
        this.currentId += 1;
      }
    });
开发者ID:SecretOnline,项目名称:bot,代码行数:28,代码来源:Logger.ts

示例2: function

app.get( '/tracker/1x1/:id', (req, resp, done) => {
  fs.appendFile('tracked.txt', req.params.id+',\n', function (err) {
    resp.writeHead(200, {'Content-Type': 'image/png' } );
    resp.end( trackerPNG );
    done();
  } );
} );
开发者ID:essential-cryptography,项目名称:essentialcryptography.com,代码行数:7,代码来源:server.ts

示例3: resolve

    return new Promise<boolean>((resolve, reject) => {
      fs.appendFile(path, content, err => {

        if (err) return reject(err);
        resolve(true);
      });
    });
开发者ID:chen-framework,项目名称:chen,代码行数:7,代码来源:filesystem.ts

示例4: Date

	proc.stderr.on('data', data => {
		var date = new Date().toLocaleString();
		fs.appendFile(`${tempFolder}/errors.log`, `${date}: ${data.toString()}`, (err) => {
			if (err) {
				throw new Error(`Could not write stderr to errors.log with the following error: ${err}`);
			};
		});
	});
开发者ID:vnvizitiu,项目名称:vscode,代码行数:8,代码来源:main.ts

示例5: Promise

 return new Promise((resolve: Function, reject: Function): void =>
     fs.appendFile(histignoreFile, 'export HISTIGNORE="stymie *:$HISTIGNORE"\n', 'utf8', (err) => {
         if (err) {
             reject(err);
         } else {
             resolve('Updated $HISTIGNORE');
         }
     })
开发者ID:btoll,项目名称:stymie-ts,代码行数:8,代码来源:install.ts

示例6: Date

	proc.stderr.on('data', data => {
		var date = new Date().toLocaleString();
		fs.appendFile(path.join(testDataPath, 'errors.log'), `${date}: ${data.toString()}`, (err) => {
			if (err) {
				throw new Error(`Could not write stderr to errors.log with the following error: ${err}`);
			};
		});
	});
开发者ID:kieferrm,项目名称:vscode,代码行数:8,代码来源:main.ts

示例7: save

 static save(log: ILogger) {
     if (LogFactory.setting.storage == LogStorage.Console) {
         console.log(log);
         return;
     }
     fs.appendFile(LogFactory.logFile, `\n${JSON.stringify(log)}`, {encoding: 'utf8'}, err => {
         console.error(err);
     });
 }
开发者ID:VestaRayanAfzar,项目名称:express-api-template,代码行数:9,代码来源:LogFactory.ts

示例8: bootstrapSbtProject

 ).then(choice => {
   if (choice === "Yes") {
     bootstrapSbtProject(buildSbtFileSource, dottyPluginSbtFileSource)
     return Promise.resolve()
   } else if (choice === "No") {
     fs.appendFile(disableDottyIDEFile, "", _ => {})
     return Promise.reject()
   }
 })
开发者ID:dotty-staging,项目名称:dotty,代码行数:9,代码来源:extension.ts

示例9: function

GLOBAL.onError = function (err: any, res:express.Response) {
    console.log('onError error\n', err);
    //TODO Remove reason in production
    res.json({error:'error', reason:err});

    var str: string = "\r\n" + new Date().toLocaleString() + "\r\n";
    str += JSON.stringify(err);

    fs.appendFile(SERVER + '/error.log', str);
};
开发者ID:shumik-vladyslav,项目名称:DigitalSignagePlayList,代码行数:10,代码来源:server.ts

示例10: updateResponseFile

function updateResponseFile(argsArray: string[], responseFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    fs.appendFile(responseFile, os.EOL + argsArray.join(os.EOL), function (err) {
        if (err) {
            defer.reject(err);
        }
        defer.resolve(responseFile);
    });
    return defer.promise;
}
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:10,代码来源:vstest.ts

示例11: writeCSV

    function writeCSV(data: any): void {
        fs.appendFile("wolfgangsee-pegel.csv", `${data.date}, ${data.level}, ${data.temperature}\n`, (err) => {
            if (err) {
                console.error("Failed to write file", err);
                return;
            }

            console.log("CSV written successfully");
        });
    }
开发者ID:thred,项目名称:wolfgangsee-pegel,代码行数:10,代码来源:wolfgangsee-pegel.ts

示例12: log

export function log(s: string) {
    let timed = new Date().toISOString() + "\t" + s;
    console.log(timed);
    fs.appendFile("./opencode.log", timed + "\n", function (err) {
        if (err) {
            return console.log("failed to write to log: " + err);
        }
    });
    logtrace.push(timed);
    if (logtrace.length > LOG_HISTORY) {
        logstart += (logtrace.length - LOG_HISTORY);
        logtrace.splice(0, logtrace.length - LOG_HISTORY);
    }
}
开发者ID:danelkhen,项目名称:desktopbrowser,代码行数:14,代码来源:utils.ts

示例13: function

 this.serialPort.on('data', function (line) {
     try {
         fs.appendFile('gps.txt', line + '\r\n');
         var parsedData = nmea.parse(line);
         debug('Parsed: ' + JSON.stringify(parsedData));
         if (parsedData.hasOwnProperty('lat')) {
             self.status.latitude = parsedData.lat / 100;
             self.status.longitude = parsedData.lon / 100;
             self.status.altitude = parsedData.alt;
         }
     } catch (err) {
         debug('Could not parse: ' + line)
     }
 });
开发者ID:pierreca,项目名称:msshuttle,代码行数:14,代码来源:gpsreader.ts

示例14: setInterval

 let id = setInterval(() => {
   let timestamp = moment().format('DD/MMM/YYYY:HH:mm:ss Z');
   let line = '127.0.0.1 user-identifier frank ['+timestamp+'] "GET /testing/apache_pb.gif HTTP/1.0" 200 2326' + '\n';
   if (n === 100){
     done();
     clearInterval(id);
   }
   if (Math.random() > 0.7) {
     appendFile('test.log', line, (err) => {
       if (err) throw err;
       n++;
     });
   }
 }, 10);
开发者ID:waltonseymour,项目名称:http-monitor,代码行数:14,代码来源:alerts.ts

示例15: fetchAndConfigure

 ).then(choice => {
   if (choice == "Yes") {
     fs.readFile(languageServerDefaultConfigFile, (err, data) => {
       if (err) throw err
       else {
         const languageServerScalaVersion = data.toString().trim()
         fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, dottyPluginSbtFile).then(() => {
           runLanguageServer(coursierPath, languageServerArtifactFile)
         })
       }
     })
   } else {
     fs.appendFile(disableDottyIDEFile, "", _ => {})
   }
 })
开发者ID:olafurpg,项目名称:dotty,代码行数:15,代码来源:extension.ts


注:本文中的fs.appendFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。