Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11,367 changed files
with
668,899 additions
and
85 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
|
||
.env | ||
.taskkey | ||
test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// @ts-check | ||
|
||
const path = require('path'); | ||
const tl = require('vsts-task-lib/task'); | ||
const fs = require('fs'); | ||
|
||
// Set the source path | ||
tl.setResourcePath(path.join(__dirname, 'task.json')); | ||
|
||
// Get the two property values | ||
const filepath = tl.getInput('filepath', true); | ||
let filecontent = tl.getInput('filecontent', true); | ||
const fileoverwrite = tl.getInput('fileoverwrite', true); | ||
const skipempty = tl.getInput('skipempty', true); | ||
const endWithNewLine = tl.getInput('endWithNewLine', false); | ||
|
||
console.log(`File path: ${filepath}`); | ||
// console.log(`File content: ${filecontent}`); | ||
|
||
/** | ||
* Create the folders for the file | ||
* @param {*} filePath | ||
*/ | ||
function ensureDirectoryExistence(filePath) { | ||
var dirname = path.dirname(filePath); | ||
// console.log(`Creating dir: ${dirname}`); | ||
if (fs.existsSync(dirname)) { | ||
return true; | ||
} | ||
ensureDirectoryExistence(dirname); | ||
fs.mkdirSync(dirname); | ||
} | ||
|
||
/** | ||
* Check if file needs to be created | ||
*/ | ||
if (filecontent || (!filecontent && !skipempty)) { | ||
filecontent = filecontent || ""; | ||
|
||
/** | ||
* Start processing the file | ||
*/ | ||
if (filepath) { | ||
// Check if file exists | ||
if (!tl.exist(filepath) || fileoverwrite) { | ||
// Create the folder, if needed | ||
ensureDirectoryExistence(filepath); | ||
// Check if new line needs to be added at the end of the file | ||
if (endWithNewLine) { | ||
filecontent = filecontent + "\n"; | ||
} | ||
// Create the file | ||
tl.writeFile(filepath, filecontent, 'utf8'); | ||
// Check if the file is created | ||
if (tl.exist(filepath)) { | ||
console.log('File created'); | ||
} else { | ||
tl.error('File not created / overwritten'); | ||
} | ||
} else { | ||
tl.error('File already exists'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,110 @@ | ||
// @ts-check | ||
|
||
const path = require('path'); | ||
const tl = require('vsts-task-lib/task'); | ||
const fs = require('fs'); | ||
|
||
// Set the source path | ||
tl.setResourcePath(path.join(__dirname, 'task.json')); | ||
|
||
// Get the two property values | ||
const filepath = tl.getInput('filepath', true); | ||
let filecontent = tl.getInput('filecontent', true); | ||
const fileoverwrite = tl.getInput('fileoverwrite', true); | ||
const skipempty = tl.getInput('skipempty', true); | ||
const endWithNewLine = tl.getInput('endWithNewLine', false); | ||
|
||
console.log(`File path: ${filepath}`); | ||
// console.log(`File content: ${filecontent}`); | ||
|
||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tl = require("azure-pipelines-task-lib/task"); | ||
const path_1 = __importDefault(require("path")); | ||
const fs_1 = __importDefault(require("fs")); | ||
/** | ||
* Create the folders for the file | ||
* @param {*} filePath | ||
* @param {string} filePath | ||
*/ | ||
function ensureDirectoryExistence(filePath) { | ||
var dirname = path.dirname(filePath); | ||
// console.log(`Creating dir: ${dirname}`); | ||
if (fs.existsSync(dirname)) { | ||
return true; | ||
} | ||
ensureDirectoryExistence(dirname); | ||
fs.mkdirSync(dirname); | ||
var dirname = path_1.default.dirname(filePath); | ||
// console.log(`Creating dir: ${dirname}`); | ||
if (fs_1.default.existsSync(dirname)) { | ||
return true; | ||
} | ||
ensureDirectoryExistence(dirname); | ||
fs_1.default.mkdirSync(dirname); | ||
} | ||
|
||
// Set the source path | ||
// tl.setResourcePath(path.join(__dirname, 'task.json')); | ||
/** | ||
* Check if file needs to be created | ||
* Task function | ||
*/ | ||
if (filecontent || (!filecontent && !skipempty)) { | ||
filecontent = filecontent || ""; | ||
|
||
/** | ||
* Start processing the file | ||
*/ | ||
if (filepath) { | ||
// Check if file exists | ||
if (!tl.exist(filepath) || fileoverwrite) { | ||
// Create the folder, if needed | ||
ensureDirectoryExistence(filepath); | ||
// Check if new line needs to be added at the end of the file | ||
if (endWithNewLine) { | ||
filecontent = filecontent + "\n"; | ||
} | ||
// Create the file | ||
tl.writeFile(filepath, filecontent, 'utf8'); | ||
// Check if the file is created | ||
if (tl.exist(filepath)) { | ||
console.log('File created'); | ||
} else { | ||
tl.error('File not created / overwritten'); | ||
} | ||
} else { | ||
tl.error('File already exists'); | ||
} | ||
} | ||
} | ||
function run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
// Get all string values | ||
const filepath = tl.getInput('filepath', true); | ||
let filecontent = tl.getInput('filecontent', false) || ""; | ||
// Get all boolean values | ||
const fileoverwrite = tl.getInput('fileoverwrite', true) === "true"; | ||
const skipempty = tl.getInput('skipempty', true) === "true"; | ||
const endWithNewLine = tl.getInput('endWithNewLine', false) === "true"; | ||
const verbose = tl.getInput('verbose', false) === "true"; | ||
if (verbose) { | ||
console.log(`VERBOSE LOGGING`); | ||
console.log(`----------------`); | ||
console.log(`'filepath': ${filepath}`); | ||
console.log(`'fileoverwrite': ${fileoverwrite}`); | ||
console.log(`'skipempty': ${skipempty}`); | ||
console.log(`'endWithNewLine': ${endWithNewLine}`); | ||
console.log(`'filecontent': ${filecontent}`); | ||
console.log(`'filecontent.length': ${filecontent.length}`); | ||
console.log(``); | ||
} | ||
else { | ||
console.log(`File path: ${filepath}`); | ||
} | ||
/** | ||
* Check if file needs to be created | ||
*/ | ||
if (filecontent || (!filecontent && !skipempty)) { | ||
filecontent = filecontent || ""; | ||
/** | ||
* Start processing the file | ||
*/ | ||
if (filepath) { | ||
// Check if file exists | ||
if (!tl.exist(filepath) || fileoverwrite) { | ||
// Create the folder, if needed | ||
ensureDirectoryExistence(filepath); | ||
// Check if new line needs to be added at the end of the file | ||
if (endWithNewLine) { | ||
filecontent = filecontent + "\n"; | ||
} | ||
if (verbose) { | ||
console.log(`Writing file with the following contents:`); | ||
console.log(filecontent); | ||
console.log(`----------------`); | ||
} | ||
// Create the file | ||
tl.writeFile(filepath, filecontent, 'utf8'); | ||
// Check if the file is created | ||
if (tl.exist(filepath)) { | ||
tl.setResult(tl.TaskResult.Succeeded, 'File created'); | ||
} | ||
else { | ||
tl.setResult(tl.TaskResult.Failed, 'File not created / overwritten'); | ||
} | ||
} | ||
else { | ||
tl.setResult(tl.TaskResult.Failed, 'File already exists'); | ||
} | ||
} | ||
} | ||
else { | ||
if (verbose) { | ||
console.log(`Skipped file creation.`); | ||
console.log(`----------------`); | ||
} | ||
} | ||
} | ||
catch (err) { | ||
tl.setResult(tl.TaskResult.Failed, err.message); | ||
} | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import tl = require('azure-pipelines-task-lib/task'); | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
|
||
/** | ||
* Create the folders for the file | ||
* @param {string} filePath | ||
*/ | ||
function ensureDirectoryExistence(filePath: string) { | ||
var dirname = path.dirname(filePath); | ||
// console.log(`Creating dir: ${dirname}`); | ||
if (fs.existsSync(dirname)) { | ||
return true; | ||
} | ||
ensureDirectoryExistence(dirname); | ||
fs.mkdirSync(dirname); | ||
} | ||
|
||
// Set the source path | ||
// tl.setResourcePath(path.join(__dirname, 'task.json')); | ||
|
||
/** | ||
* Task function | ||
*/ | ||
async function run() { | ||
try { | ||
|
||
// Get all string values | ||
const filepath = tl.getInput('filepath', true); | ||
let filecontent = tl.getInput('filecontent', false) || ""; | ||
// Get all boolean values | ||
const fileoverwrite = tl.getInput('fileoverwrite', true) === "true"; | ||
const skipempty = tl.getInput('skipempty', true) === "true"; | ||
const endWithNewLine = tl.getInput('endWithNewLine', false) === "true"; | ||
const verbose = tl.getInput('verbose', false) === "true"; | ||
|
||
if (verbose) { | ||
console.log(`VERBOSE LOGGING`); | ||
console.log(`----------------`); | ||
console.log(`'filepath': ${filepath}`); | ||
console.log(`'fileoverwrite': ${fileoverwrite}`); | ||
console.log(`'skipempty': ${skipempty}`); | ||
console.log(`'endWithNewLine': ${endWithNewLine}`); | ||
console.log(`'filecontent': ${filecontent}`); | ||
console.log(`'filecontent.length': ${filecontent.length}`); | ||
console.log(``); | ||
} else { | ||
console.log(`File path: ${filepath}`); | ||
} | ||
|
||
/** | ||
* Check if file needs to be created | ||
*/ | ||
if (filecontent || (!filecontent && !skipempty)) { | ||
filecontent = filecontent || ""; | ||
|
||
/** | ||
* Start processing the file | ||
*/ | ||
if (filepath) { | ||
// Check if file exists | ||
if (!tl.exist(filepath) || fileoverwrite) { | ||
// Create the folder, if needed | ||
ensureDirectoryExistence(filepath); | ||
// Check if new line needs to be added at the end of the file | ||
if (endWithNewLine) { | ||
filecontent = filecontent + "\n"; | ||
} | ||
|
||
|
||
if (verbose) { | ||
console.log(`Writing file with the following contents:`); | ||
console.log(filecontent); | ||
console.log(`----------------`); | ||
} | ||
|
||
// Create the file | ||
tl.writeFile(filepath, filecontent, 'utf8'); | ||
// Check if the file is created | ||
if (tl.exist(filepath)) { | ||
tl.setResult(tl.TaskResult.Succeeded, 'File created'); | ||
} else { | ||
tl.setResult(tl.TaskResult.Failed, 'File not created / overwritten'); | ||
} | ||
} else { | ||
tl.setResult(tl.TaskResult.Failed, 'File already exists'); | ||
} | ||
} | ||
} else { | ||
if (verbose) { | ||
console.log(`Skipped file creation.`); | ||
console.log(`----------------`); | ||
} | ||
} | ||
} catch (err) { | ||
tl.setResult(tl.TaskResult.Failed, err.message); | ||
} | ||
} | ||
|
||
run(); |
Oops, something went wrong.