-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): fix for pkg_npm single directory artifact dep case
Also fixes the dependency on bazel-bin for the .pack & .publish scripts. This fixes an issue where pkg_npm has a single dep which is a directory artifact but the contents of that dep are not re-rooted. This is the expected behaviour as the only way to create a valid npm package with a package.json at the root is to re-root to the output directory of the dep. The fix is actually to not copy anything but to just forward the directory artifact dep onto the default info of pkg_npm. Some refactoring done so that the npm scripts are generated in a separate action from the package.js which is not run in the single directory artifact dep case.
- Loading branch information
1 parent
b459d6d
commit 5a7c1a7
Showing
6 changed files
with
190 additions
and
63 deletions.
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,39 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* @fileoverview This script generates npm pack & publish shell scripts from | ||
* a template. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
function main(args) { | ||
const [outDir, packPath, publishPath, runNpmTemplatePath] = args; | ||
const npmTemplate = fs.readFileSync(runNpmTemplatePath, {encoding: 'utf-8'}); | ||
const cwd = process.cwd(); | ||
if (/[\//]sandbox[\//]/.test(cwd)) { | ||
console.error('Error: npm_script_generator must be run with no sandbox'); | ||
process.exit(1); | ||
} | ||
fs.writeFileSync(packPath, npmTemplate.replace('TMPL_args', `pack "${cwd}/${outDir}"`)); | ||
fs.writeFileSync(publishPath, npmTemplate.replace('TMPL_args', `publish "${cwd}/${outDir}"`)); | ||
} | ||
|
||
if (require.main === module) { | ||
process.exitCode = main(process.argv.slice(2)); | ||
} |
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
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
Oops, something went wrong.