void/build/lib/amd.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2024-09-11 02:37:36 +00:00
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
2024-09-24 04:46:08 +00:00
exports.setAMD = setAMD;
exports.isAMD = isAMD;
2024-09-11 02:37:36 +00:00
const path = require("path");
const fs = require("fs");
// TODO@esm remove this
const outDirectory = path.join(__dirname, '..', '..', 'out-build');
2024-09-24 04:46:08 +00:00
const amdMarkerFile = path.join(outDirectory, 'amd');
function setAMD(enabled) {
2024-09-11 02:37:36 +00:00
const result = () => new Promise((resolve, _) => {
if (enabled) {
fs.mkdirSync(outDirectory, { recursive: true });
2024-09-24 04:46:08 +00:00
fs.writeFileSync(amdMarkerFile, 'true', 'utf8');
console.warn(`Setting build to AMD: true`);
2024-09-11 02:37:36 +00:00
}
else {
2024-09-24 04:46:08 +00:00
console.warn(`Setting build to AMD: false`);
2024-09-11 02:37:36 +00:00
}
resolve();
});
2024-09-24 04:46:08 +00:00
result.taskName = 'set-amd';
2024-09-11 02:37:36 +00:00
return result;
}
2024-09-24 04:46:08 +00:00
function isAMD(logWarning) {
2024-09-11 02:37:36 +00:00
try {
2024-09-24 04:46:08 +00:00
const res = (typeof process.env.VSCODE_BUILD_AMD === 'string' && process.env.VSCODE_BUILD_AMD.toLowerCase() === 'true') || (fs.readFileSync(amdMarkerFile, 'utf8') === 'true');
2024-09-11 02:37:36 +00:00
if (res && logWarning) {
2024-09-24 04:46:08 +00:00
console.warn(`[amd] ${logWarning}`);
2024-09-11 02:37:36 +00:00
}
return res;
}
catch (error) {
return false;
}
}
2024-09-24 04:46:08 +00:00
//# sourceMappingURL=amd.js.map