Skip to content

Commit

Permalink
use strict mode for build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Jan 29, 2024
1 parent 3407df3 commit 8e8b2f1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions examples/electron/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* LittleJS Build System
*/

'use strict';

const PROGRAM_NAME = 'game';
const BUILD_FOLDER = 'build';
const sourceFiles =
Expand Down
2 changes: 2 additions & 0 deletions examples/js13k/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* LittleJS Build System
*/

'use strict';

const PROGRAM_NAME = 'game';
const BUILD_FOLDER = 'build';
const sourceFiles =
Expand Down
2 changes: 2 additions & 0 deletions examples/starter/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* LittleJS Build System
*/

'use strict';

const PROGRAM_TITLE = 'Little JS Starter Project';
const PROGRAM_NAME = 'game';
const BUILD_FOLDER = 'build';
Expand Down
2 changes: 2 additions & 0 deletions examples/typescript/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* LittleJS Build System
*/

'use strict';

const PROGRAM_NAME = 'game';
const BUILD_FOLDER = 'build';
const ROOT_FOLDER = 'examples/typescript';
Expand Down
18 changes: 9 additions & 9 deletions src/engineBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @namespace Build
*/

'use strict';

const ENGINE_NAME = 'littlejs';
const BUILD_FOLDER = 'build';
const SOURCE_FOLDER = 'src';
Expand Down Expand Up @@ -54,15 +56,15 @@ Build
'Build Engine -- all',
`${BUILD_FOLDER}/${ENGINE_NAME}.js`,
[`${SOURCE_FOLDER}/engineDebug.js`, ...engineSourceFiles],
[], license
[], true
);

Build
(
'Build Engine -- release',
`${BUILD_FOLDER}/${ENGINE_NAME}.release.js`,
[`${SOURCE_FOLDER}/engineRelease.js`, ...engineSourceFiles],
[], license
[], true
);

Build
Expand Down Expand Up @@ -95,20 +97,18 @@ console.log(`Engine built in ${((Date.now() - startTime)/1e3).toFixed(2)} second

// A single build with its own source files, build steps, and output file
// - each build step is a callback that accepts a single filename
function Build(message, outputFile, files=[], buildSteps=[], topOfFileText)
function Build(message, outputFile, files=[], buildSteps=[], isPrimaryBuild)
{
console.log(message);

const isPrimaryBuild = !!topOfFileText;

// copy files into a buffer
let buffer = '';
if (topOfFileText)
buffer += topOfFileText + '\n';

// add strict mode to top of the first file
if (isPrimaryBuild)
{
// add license and strict mode to top
buffer += license + '\n';
buffer += "'use strict';\n\n";
}

for (const file of files)
{
Expand Down

0 comments on commit 8e8b2f1

Please sign in to comment.